Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the lengths/limits C preprocessor as a language creation tool? Where can I learn more about these?

Tags:

People also ask

What is the preprocessor in C language?

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.

What is C preprocessor explain any two C preprocessor commands with example?

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.

How many types of preprocessor directives are there in C?

Four Major Types of Preprocessor Directives.

What is #define MAX in C?

+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:

  1. Are there other examples of this approach to bootstrapping a language off of C?

  2. Is the source to Stroustrup's original work available anywhere?

  3. Where could I learn more about the specifics of utilizing this technique?

  4. 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?