title | category | intro |
---|---|---|
C Preprocessor |
C-like |
Quick reference for the [C macro preprocessor](https://en.m.wikipedia.org/wiki/C_preprocessor), which can be used independent of C/C++.
|
{: .-three-column}
$ cpp -P file > outfile
#include "file"
#define FOO
#define FOO "hello"
#undef FOO
#ifdef DEBUG
console.log('hi');
#elif defined VERBOSE
...
#else
...
#endif
#if VERSION == 2.0
#error Unsupported
#warning Not really supported
#endif
#define DEG(x) ((x) * 57.29)
#define DST(name) name##_s name##_t
DST(object); #=> object_s object_t;
#define STR(name) #name
char * a = STR(object); #=> char * a = "object";
#define LOG(msg) console.log(__FILE__, __LINE__, msg)
#=> console.log("file.txt", 3, "hey")