debug, programming

Assert macros cause compiling errors.

I’m working on compiling a Objective-C framework that wraps OpenCV, so it can be used with Swift code. ( Project link.) I have it compiling for iOS, and I am adding a target for OS X. When I tried compiling I got an error where the check() macro defined in AssertMacros.h was expanding in a header file that declares a method check() in a template class. I found other projects are having trouble with this, and Apple was aware of it too. The macros were renamed to include leading underscores and capital letters on the first word, but they redefine them to the old naming for compatibility. Plus, the old names are enabled by default. The comments in AssertMacros.h explain the issue, and tell you how to disable the old names.

So, to keep note of this issue. Adding,

__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0

to the “Preprocessor Macros” of the build settings for the target fixed the issue. Plus, you can add a #define with this macro to individual files to be more selective, but I would say it is best to add it to the build settings and avoid the old names if you use these macros.

Advertisements
Standard