[SERVER-8897] Avoid using non-portable ##__VA_ARGS comma elision construct in mongo initializers facility Created: 07/Mar/13  Updated: 11/Jul/16  Resolved: 22/Mar/13

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 2.5.0

Type: Improvement Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Unassigned
Resolution: Done Votes: 0
Labels: c++11
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Participants:

 Description   

We currently make use of the GCC extension that gives special behavior to the token pasted ##_VA_ARGS_ expression, such that the comma before the ## is elided:

http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html

While this extension is widely honored by other compilers, C99 actually introduced a specification for variadic macros, and that specification does not honor this construction.

As a result, when we compile with -std=c++11 we get the C99 version of variadic macros rather than the GNU version, so the commas are no longer elided as our macros expcet and the mongo initializer stuff breaks.

In the interest of avoiding non-portable compiler extensions, even if widely implemented in other compilers, we should avoid using the token-pasting trick and find another way to make the mongo initializer macros work.



 Comments   
Comment by auto [ 08/Mar/13 ]

Author:

{u'date': u'2013-03-07T19:42:30Z', u'name': u'Andrew Morrow', u'email': u'acm@10gen.com'}

Message: SERVER-8897 Don't use non-portable variadic comma elision
Branch: master
https://github.com/mongodb/mongo/commit/13ddc4ee6eb6717808ce3726bd3b59eb55e48b58

Generated at Thu Feb 08 03:18:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.