how to define a comment macro working in xcode on the mac
it is quite useful to comment in/out lines using a macro for debug mode.
Unfortunately the normal approaches don't work on the Mac Xcode.
I tried / ## /
as well as using a two step macro开发者_开发问答 like
#define COMMENT SLASH(/)
#define SLASH(s) /##s
which I also found in the web.
But neither works.
Do you have an idea which way to define a comment macro. Thanks!
Why not this?
#ifdef DEBUG
// Do debug stuff here
NSAssert(...);
#endif
I am curious how / why you would use a comment macro.
Same Problem here...
The answer seems to be that we expect a traditional while XCode uses a ISO-conform preprocessor (see http://developer.apple.com/library/mac/#documentation/DeveloperTools/gcc-4.2.1/cpp/Traditional-macros.html#Traditional-macros) There seems to be the possibility to change the options of the preprocessor, but who knows what you will break in the code from the apple SDKs.
I went through my code and changed my uses of such macros so that the macro is not followed by the code that should be hidden, but instead pass the code as parameter to the macro... This way the code remains readable (not clobbered with #ifdefs)... It only gets ugly if your debug-code contains ","
精彩评论