The C Preprocessor and pound Defines
Early draft, may not be useful to read
Programming in C almost always involves using and learning about the pre processor. The preprocessore is a program that takes your program as input and outputs the program somewhat transformed.
The #define may be the most important part of the preprocessor. A #define simply defines one symbol as a shorthand for another symbol, all the data is text or string. For example
#define BIG 255
Simply means that every place that the string BIG occurs in the program it means the string 255. The preprocessor actually makes this substution. There is no notion that 255 is a number, it is just a string, later the compiler will see the 255 and it, not the preprocessor will view it as a number.
Calculations
#define BIGGER 255 + 5
just looks like a calculation, actually it means that BIGGER is just the same as the text 250 + 5, only later in the compiler will 255 + 5 be interperted as a number where:
x = a + BIGGER;
becomes
x = a + 255 + 5;
Other places in this wiki where the preprocessor is discussed:
boostc h files
External links to preprocessor information: