[Reference] file and line
#define LOG(msg) console.log(__FILE__, __LINE__, msg)
#=> console.log("file.txt", 3, "hey")
[Reference] Stringification
#define STR(name) #name
char * a = STR(object); #=> char * a = "object";
[Reference] Token concat
#define DST(name) name##_s name##_t
DST(object); #=> object_s object_t;
[Reference] Macro
#define DEG(x) ((x) * 57.29)
[Reference] Error
#if VERSION == 2.0
#error Unsupported
#warning Not really supported
#endif
[Reference] If
#ifdef DEBUG
console.log('hi');
#elif defined VERBOSE
...
#else
...
#endif
[Reference] Defines
#define FOO
#define FOO "hello"
#undef FOO
[Reference] Includes
#include "file"
[Reference] Compiling
$ cpp -P file > outfile
Reference
Top comments (0)