The C preprocessor is a macro processor that is used automatically by the C compiler to transform your program before actual compilation. It is called a macro processor because it allows you to define macros, which are brief abbreviations for longer constructs.
File InclusionThis type of preprocessor directive tells the compiler to include a file in the source code program. There are two types of files that can be included by the user in the program: Header files or Standard files: These files contain definitions of pre-defined functions like printf(), scanf(), etc.
Four Major Types of Preprocessor Directives.
+2147483647. Defines the maximum value for an int. UINT_MAX. 4294967295. Defines the maximum value for an unsigned int.
In his FAQ, Bjarne Stroustrup says:
To build [Cfront, the first C++ compiler], I first used C to write a "C with Classes"-to-C preprocessor. "C with Classes" was a C dialect that became the immediate ancestor to C++... I then wrote the first version of Cfront in "C with Classes".
When I read this, it piqued my interest in the C preprocessor. I'd seen its macro capabilities as suitable for simplifying common expressions but hadn't thought about its ability to significantly add to syntax and semantics on the level that I imagine bringing classes to C took.
So now I have some questions on my mind:
Are there other examples of this approach to bootstrapping a language off of C?
Is the source to Stroustrup's original work available anywhere?
Where could I learn more about the specifics of utilizing this technique?
What are the lengths/limits of that approach? Could one, say, create a set of preprocessor macros that let someone write in something significantly Lisp/Scheme like?
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