I recall a claim made by one of my professors in an introductory C course. He stated that the #define
preprocessor command enables a programmer to create a constant for use in later code, and that the command was a part of the C language.
/* Is this truly C code? */
#define FOO 42
Since this was in an introductory programming class, I suspect that he was merely simplifying the relationship between the source file and the compiler, but nevertheless I wish to verify my understanding.
Are preprocessor statements completely independent from the C language (dependent on the specific compiler used) or are they explicitly described in the C99 standard? Out of curiosity, did K&R ever mention preprocessor macros?
Yes, the standard describes the preprocessor. It's a standardized part of the C language.
Note that #include
, which is essential for modularization of code, is a preprocessor directive.
In the publically-available draft of the C99 standard, the preprocessor is described in section 6.10.
The preprocessor is indeed part of the C and C++ standard (chapter 16 in the C++ standard) and the standards describe how the preprocessor and the language interact (for example it is illegal to re-#define
the C keywords).
However the C preprocessor can work with other languages than C for any kind of simple file preprocessing (I have seen it used with LaTeX files for example).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With