Preprocessor: Concatenate words to single identifiers
The preprocessor directive ## (two hashes or number signs, aka the token pasting operator) allows to concatenate two symbols into one.
#include <stdio.h>
// CONCAT(foo, bar) -> foobar
#define CONCAT(id1, id2) id1##id2
int main() {
// Declare a variable named FooBar, after running the
// preprocessor, the line will read:
//
// int FooBar
//
int CONCAT(Foo, Bar);
FooBar = 42;
printf("FooBar = %d\n", FooBar);
}
It doesn't matter if spaces are to the left or right side of the hashes (ident##other is equal to ident ## other):
#include <stdio.h>
#define DECLARE_NUM_A(id1, id2) int id1##id2
#define DECLARE_NUM_B(id1, id2) int id1 ##id2
#define DECLARE_NUM_C(id1, id2) int id1 ## id2
int main() {
//
// The following three lines are expanded by the preprocessor to
// int numOne;
// int numTwo
// int numThree
//
DECLARE_NUM_A( num, One );
DECLARE_NUM_B( num, Two );
DECLARE_NUM_C( num, Three );
numOne = 42;
numTwo = 99;
numThree = -1;
printf("The numbers are %d %d %d\n", numOne, numTwo, numThree);
}