Monday, December 17, 2012 [Tweets] [Favorites]

Objective-C Pitfalls

Mike Ash:

The preprocessor splits macro arguments on commas. […] These macros conceptually take a single argument, but they’re declared to take variable arguments to avoid this problem. By taking ... and using __VA_ARGS__ to refer to “the argument”, multiple “arguments” with commas are reproduced in the macro’s output. You can take the same approach to make your own macros safe from this problem, although it only works on the last argument of a multi-argument macro.


Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment