Native C / C++
C is a compiled language. This means the compiler needs to take the code, process it and create an executable.
Every statement ends with a semi-colon
FAQ
1) What is WINAPI ?
__declspec(dllexport) int WINAPI xlAutoOpen
#const WINAPI __stdcall
The WINAPI is just a macro/constant definition
Any function that you want to call from Excel must include the modifier "__stdcall"
2) What is '__stdcall' ?
int __stdcall xlAutoOpen
This is a windows calling convention that defines stack cleanup, argument passing and symbol naming
This function cleans up the stack automatically.
3) What is '__cdecl' ?
This is a windows calling convention that defines stack cleanup, argument passing and symbol naming
The function does not clean up the stack and relies on the caller to do it.
This is the default on Win32.
4) What calling convention is used in 64-bit Excel.
__stdcall is the only convention that is used.
pg 93
5) What is '__declspec()' ?
This is a compiler directive that can be used to add attributes to declarations.
6) What is 'extern "C"' ?
This can be added to tell the compiler not to apply C++ name mangling and to export this symbol as if it was written in C.
7) What is #pragma ?
This is a compiler directive that embeds instructions inside the compiled object file (.obj).
8) What does this mean ?
static const char* MyFunction()
This declares a function that returns a pointer to a string that must not be modified.
The static means that the function is only visible in this particular (.c) file.
9) What does this mean ?
BOOL WINAPI DllMain()
This is a callback function that Windows calls automatically when your XLL is loaded/unloaded and runs before xlAutoOpen.
10) What does LPSTR stand for ?
This stands for "Long Pointer to String" and is a Windows API data type (not C or C++ specific)
C Versions
| Version | |
| C23 | released 2024 |
| C17 | released 2018 |
| C11 | released 2011 |
| C99 | released 1999 |
Data Types and Modifiers
There are four main data types
char
int - for whole numbers
float - for decimals
double - for decimals
There are also four different modifiers
signed -
unsigned -
short -
long - (there is even long long)
C does not have a boolean data type
It is often defined as follows:
#define BOOL char;
#define FALSE 0;
#define TRUE 1;
int numbers[10]
int multi[x][y]
if (true) {
} else if (true)
} else {
}
Other Operators
AND operator &&
OR operator ||
NOT operator !=
Strings are arrays of characters
These are referred to as C-Strings (not to be confused with C++ Strings)
char name[] = "some text"; //automatic
char name[10] = "some text"; //adding one to the length, to include the string termination character)
Loops
for (i=0; i<10; i++) {
}
while (true) {
break / continue
}
Functions
All arguments are passed by value
Must be declared at the top before they are used
\n = newline
Static Variables
Static functions - the scope is not global, only that file
Pointers are used for
A pointer is a simple integer variable that holds a memory address that points to a value
Strings
Dynamic memory allocation
Function arguments by reference
Building data structures
Dereferencing
This is the name used to describe getting the value that the pointer refers to
You can deference a pointer using the asterisk operator (*)
Addressing
This is the name used to describe getting the pointer in memory for a variable
You can get the address of a variable using the ampersand operator (&)
char c = 'A';
char *pc = &c;
Structures
These are data types that contain a group of data types (or pointers)
struct point {
int x;
int y;
}
struct point p;
p.x = 10;
p.y = 5
myfunc(p);
TypeDefs
These are structs but allow us to declare an instance of this struct without having to use the struct keyword.
typedef struct {
int x;
int y;
} point;
point p;
Type Casting
Writing = "(person *) malloc(sizeof (person))"
This changes the type of the pointer returned to be person
Library Files - stdio.h
printf
strncmp - compares 2 strings
strlen - returns length of string
strncat - appends characters to the end
sizeof - not an actual function, the compiler interprets and translates it to the actual size
malloc - memory allocation, this returns a "void pointer" which is a pointer that does not have a type
free - does not delete the variable, just the data that it points to
wcsncpy -
strncpy -
wcslen -
Sample Code
#include <stdio.h>
int main() {
int x;
printf("Enter a number: ");
scanf("%d", &x);
printf("You entered: %d\n", x);
return 0;
}
Native C++
C++ - incudes the bool data type
C++ Versions
| Version | |
| C++ 23 | released 2024 |
| C++ 20 | released 2020 |
| C++ 17 | released 2017 |
| C++ 14 | released 2014 |
| C++ 11 | released 2011 |
| C++ 03 | released 2003 |
| C++ 98 | released 1998 |
Visual Studio Versions
| Version | ||
| Visual C++ 14.30 | released in 2021 | |
| Visual C++ 14.20 | released in 2019 | |
| Visual C++ 14.1 | released in 2017 | |
| Visual C++ 14.0 | released in 2015 | |
| Visual C++ 12.0 | Visual Studio 2013 | released in 2013 |
| Visual C++ 11.0 | Visual Studio 2012 | released in 2012 |
| Visual C++ 10.0 | Visual Studio 2010 | released in 2010, with .NET 4.0 |
| Visual C++ 9.0 | Visual Studio 2008 | released in 2007, with .NET 3.5 |
| Visual C++ 8.0 | Visual Studio 2005 | released in 2005, with .NET 2.0, with C++/CLI |
| Visual C++ 7.0 | Visual Studio .NET | released in 2002, with .NET 1,0, with Managed C++ |
| Visual C++ 6.0 | released in 1998, (also known as VC6), bundled with Visual Studio 6.0 |
C++ Libraries
STL - Standard Template Library
Provides essential data structures and algorithms like vectors, lists, maps, and sorting. This comes bundled with C++ itself
Boost -
A large collection of peer-reviewed libraries that extend STL. - Includes utilities for strings, math, threading, file handling
Qt -
A powerful cross-platform framework for GUI development. - Used to build applications with windows, buttons, menus. Also includes modules for networking, databases, and multimedia.
C++ Library Headers
iostream - library header
std::cin >> x;
std::cout << "Hello " << x;
std::cerr << "Error!";
std::clog << "Log message";
std::endl
cmath - library header
std::abs()
std::sqrt();
std::pow(x,y);
fstream - library header
std::ifstream
std::ofstream
std::fstream
C++ Code
#include <iostream>
using namespace std;
int main() {
int x;
cout << "Enter a number: ";
cin >> x;
cout << "You entered: " << x << endl;
return 0;
}
Project Properties > C/C++ > General > Debug information format (/Zi)
Project Properties > Linker > Debugging > Generate program database file (/DEBUG)
Project Properties > Linker > Debugging > Generate debug info
Debug > Attach to Process
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext