Objective-C preprocessor directive for ‘if not’
you could try: #if !(SOME_VARIABLE) // Do something #endif
you could try: #if !(SOME_VARIABLE) // Do something #endif
It is possible to insert a hash token into the preprocessed token stream. You can do it as follows: #define MACRO(hash, name) hash include name MACRO(#,”hello”) —expands to: # include “hello” However, the standard explicitly rules out any further analysis of such line for the existence of preprocessing directives [cpp.rescan]: The resulting completely macro-replaced preprocessing … Read more
[Update: Adrian McCarthy comments below saying MSVC++ 2017 fixes this] GCC and clang are right, VC++ is wrong. 2.2 Phases of translation [lex.phases]: […] The source file is decomposed into preprocessing tokens (2.5) and sequences of white-space characters (including comments). Preprocessing directives are executed, […] And 2.5 Preprocessing tokens [lex.pptoken] lists string-literals amongst the tokens. … Read more
Update Looks like the bug report was marked as a duplicate of this one which has an update which says: A fix for this issue has been checked into the compiler sources. The fix should show up in the next major release of Visual C++. Original As remyabel pointed out this is a reported bug. … Read more
No, you can’t unstringify something.
As greyfade pointed out, your ___T___ trick doesn’t work because the preprocessor is a pretty simple creature. An alternative approach is to use pragma directives: // juice includes here #pragma push_macro(“T”) #undef T // include boost headers here #pragma pop_macro(“T”) That should work in MSVC++ and GCC has added support for pop_macro and push_macro for … Read more
No, in general you should not use const-qualified objects in C to create names constants. In order to create a named constant in C you should use either macros (#define) or enums. In fact, C language has no constants, in the sense that you seem to imply. (C is significantly different from C++ in this … Read more
In MSVC you could use push_macro pragma, GCC supports it for compatibility with Microsoft Windows compilers. #pragma push_macro(“MACRONAME”) #undef MACRONAME // some actions #pragma pop_macro(“MACRONAME”)
Implementation defined. See what is the difference between #include <filename> and #include “filename”.
It’s possible to write a macro that evaluates to the number of arguments it’s called with. (I couldn’t find a link to the place where I first saw it.) So you could write MAX_OF_N() that would work as you’d like, but you’d still need all the numbered macros up until some limit: #define MAX_OF_1(a) (a) … Read more