[英]Create custom #warning flags
我正在构建一个商业应用程序,我们正在使用一些GPL代码来帮助我们。
如何添加#warning
或#error
语句,以便在为调试构建代码时,它会发出警告,但是当我们构建发布时它会抛出错误?
我可以:
#warning this code is released under a CCL licensing scheme, see Source_Code_License.rtf
#warning this code is not LGPL-compliant
#warning this code was copied verbatim from a GP Licensed file
在文件的开头,但我可以做得更好吗? 如果包含文件,是否有更好的标记文件的方法?
我正在使用带有gcc或clang的Objective-C ++。
#ifdef SOME_SYMBOL
#error "foobar"
#else
#warning "foobar"
#endif
NDEBUG的目的略有不同(控制断言),可能是#undef并有选择地重新定义(重新包含assert.h以实现更改),因此它可能不是正确的符号。 但它是一个标准的宏,可以使用。
请注意,#error是标准的,但#warning是一个扩展名。
请改用#pragma message。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.