Use of GNU C extensions in XCTest framework headers

Originator:macmade
Number:rdar://17610722 Date Originated:09-Jul-2014 08:49 PM
Status:Duplicate Resolved:
Product:Developer Tools Product Version:Xcode 6.0 6A254o / OS X 10.10 14A283o
Classification:Other Bug Reproducible:Always
 
Summary:
Many macros of the XCTest framework, like those defined in XCTestAssertionsImpl.h make use of GNU extensions of the C language, mainly named variadic macros.

This can be very annoying with a project intended to be strictly compatible with the ISO-C standard, or simply with clang configured to a high error reporting level.

In such a context, the only way to have the unit test bundle pass compilation is to lower the warning levels by ignoring the corresponding flags.
Obviously, lowering the error reporting level is not something very fancy nor clever in the context of unit testing…

ISO-C supports (unnamed) variadic macros, with __VA_ARGS__, so there’s just no need for these fancy GNU named variadic macros stuff.

Code like:

#define _XCTPrimitiveFail(test, format...) \
({ \
    _XCTRegisterFailure(test, _XCTFailureDescription(_XCTAssertion_Fail, 0), format); \
})

Could (should) be simply replaced by:

#define _XCTPrimitiveFail(test, ...) \
({ \
    _XCTRegisterFailure(test, _XCTFailureDescription(_XCTAssertion_Fail, 0), __VA_ARGS__); \
})

The is not a big deal. Nothing complicated nor error-prone.
And then everything would be fine and ISO-C compliant.

Steps to Reproduce:
1. Attached is a sample Xcode project which demonstrates the issue
2. Open the Xcode project
3. Runs the tests

Expected Results:
The unit tests should pass.

Actual Results:
The build of the unit test bundle fails with more than 20 errors caused by the use of GNU named variadic macros in XCTest headers. 
The compiler stops the compilation because too many errors occurred.

Version:
Xcode version 6.0 (6A254o) / OS X version 10.10 (14A283o)

Notes:


Configuration:


Attachments:
'XCTestBug.zip' was successfully uploaded.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!