Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-8897

Avoid using non-portable ##__VA_ARGS comma elision construct in mongo initializers facility

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.5.0
    • Affects Version/s: None
    • Component/s: Internal Code
    • Labels:
    • Fully Compatible

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: