Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-12333

Arguments to function-like macros are not expanded before substitution

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • Qt Creator 3.2.0-beta1, Qt Creator 3.4.0-beta1
    • C/C++/Obj-C++ Support
    • None

    Description

      The preprocessor does not expand arguments of function-like macros before substitution. Instead, it seems to expand the result of a function-like macro only after substitution.

      #define BEFORE AFTER
      #define SHOW(a, b) show_##a show_##b
      #define TEST(a) SHOW(test_##a, a)
      TEST(BEFORE)
      
      • QtCreator result: show_test_BEFORE show_BEFORE
      • g++ -E result: show_test_BEFORE show_AFTER

      I think the rule is that macro arguments are expanded unless they're used with stringification or token pasting. See https://gcc.gnu.org/onlinedocs/cpp/Argument-Prescan.html .

      This causes failures with most uses of the boost preprocessor library and is likely the root cause behind QTCREATORBUG-11243.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              erikv Erik Verbruggen
              ckamm Christian Kamm
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes