如何定义在Mac上的xcode中工作的注释宏
在调试模式下使用宏注释输入/输出行非常有用。
不幸的是,正常的方法在 Mac Xcode 上不起作用。
我尝试了 / ## /
以及使用两步宏,就像
#define COMMENT SLASH(/)
#define SLASH(s) /##s
我在网上找到的那样。
但两者都不起作用。
您知道如何定义注释宏吗? 谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不是这个?
我很好奇你如何/为什么使用注释宏。
Why not this?
I am curious how / why you would use a comment macro.
同样的问题在这里...
答案似乎是我们期望传统的 XCode 使用符合 ISO 的预处理器(请参阅 http://developer.apple.com/library/mac/#documentation/DeveloperTools/gcc-4.2.1/cpp /Traditional-macros.html#Traditional-macros)
似乎可以更改预处理器的选项,但谁知道你会破坏 Apple SDK 的代码中的内容。
我检查了我的代码并更改了对此类宏的使用,以便宏后面不会跟着应该隐藏的代码,而是将代码作为参数传递给宏...
这样代码仍然可读(不会被 #ifdefs 破坏)...
如果你的调试代码包含“,”,它只会变得丑陋
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 ","