How to use #if inside #define in the C preprocessor?

You can simulate conditionals using macro token concatenation as follows: #define DEF_CONST(b_const) DEF_CONST_##b_const #define DEF_CONST_true const #define DEF_CONST_false Then, /* OK */ DEF_CONST(true) int x; /* expands to const int x */ DEF_CONST(false) int y; /* expands to int y */ /* NOT OK */ bool bSomeBool = true; // technically not C 🙂 DEF_CONST(bSomeBool) … Read more

Can you make custom operators in C++?

Yes! (well, sort of) There are a couple publicly available tools to help you out. Both use preprocessor code generation to create templates which implement the custom operators. These operators consist of one or more built-in operators in conjunction with an identifier. Since these aren’t actually custom operators, but merely tricks of operator overloading, there … Read more

How to detect LLVM and its version through #define directives?

The __llvm__ and __clang__ macros are the official way to check for an LLVM compiler (llvm-gcc or clang) or clang, respectively. __has_feature and __has_builtin are the recommended way of checking for optional compiler features when using clang, they are documented here. Note that you can find a list of the builtin compiler macros for gcc, … Read more

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.