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

Preprocessor should expand macros that are passed to function-like macros in define

    XMLWordPrintable

Details

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

    Description

      Sorry for the long title

      When a #define references a function-like macro, and passes values to it, the values need to be expanded before they're passed to the function. This mostly affects concatenation operator.

      This behavior is different on calls from other statements which are not #defines.

      #define concat(x,y) x ## y
      #define xconcat(x,y) concat(x,y)
      
      #define NUM 42
      int foo1 = concat(0x, NUM); // should be expanded as 0xNUM, which of course won't compile
      int foo2 = xconcat(0x, NUM); // should be expanded as 0x42

      Attachments

        Issue Links

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

          Activity

            People

              kosjar Nikolai Kosjar
              orgads Orgad Shaneh
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes