contents   index   previous   next



#define <name> <body>|<name>(<args>) <body>
#undef <name>

The #define command defines a preprocessor macro. When the preprocessor encounters the macro name, it replaces it with the tokens in the specified body. This directive can also be used to defined parameterized macros. The Nombas preprocessor follows the same rules as C regarding the scanning and rescanning of macro expansions. Once a macro is expanded the preprocessor will rescan the resulting tokens for other defined macros. If other macros are found during the rescanning phase, they are expanded and scanned recursively. If a macro is found while scanning its own expansion, directly or as a result of recursion, that macro is not expanded. For instance, given the following macro definitions:

 

#define A B B

#define B C C

#define C A A

The code

 

A B C 

will be expanded into

 

A A A A A A A A B B B B B B B B C C C C C C C C 

When defining parameterized macros, the ‘#’ character can be used to turn macro parameters into string tokens. For example, the following code results in Hello World! being printed to standard output:

 

#define FOO(x) #x

System.out.println(FOO(Hello World!));

 

 

The #undef command is used to undefined a macro.

 


#if #elif #ifdef #ifndef #else#endif