18 ms·
The first one (?:) is not standard but only a GNU extension, so be carefull with that one.
by Genmutant 12y ago
The first one (?:) is not standard but only a GNU extension, so be carefull with that one.
- guillaumec 12y agoThanks for letting me know. I though this was in the standard. I will fix the post.
- imurray 12y agoOne can try to catch use of gcc extensions with: gcc -std=c99 -pedantic
- guillaumec 12y agoI usually don't use those flags because some extensions are well supported (as long as I stay away from MSVC), and so I feel free to use them if they help me. One example is the ##__VAR_ARGS__ gnu extension that is not strictly c99, but not using it is just too painful for variadic macros.
- deleted 12y ago[deleted]
- kps 12y agoC11 standardizes variadic macros — see §6.10.3 Macro replacement http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
- codys 12y agoYes, even c99 has them IIRC. The issue that was called out, however, was the use of "FOO(x, ## __VA_ARGS__)". GNU C has an extension that causes the ',' to be removed if __VA_ARGS__ is empty. AFAIK, it is not standard.
- kps 12y agoAs a note to anyone interested in what's in the standards: the C committee openly publishes its work in progress, including documents that are functionally identical to the official standards except for the working at the front that says ‘this is an official standard’. C99: http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf (post-publication ‘draft’ including technical corrigenda 1–3) C11: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf (final draft as voted on) Similarly for C++: C++11: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n333... C++14: http://open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf http://open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pd...
- cfrs 12y agoIt is also supported in clang.
- sswezey 12y agoYep, it's very nice for a nil/default assignment in Objective-C like |= in Ruby