Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Macros for Qt Creator code model
Qt 6.11 is out! See what's new in the release blog

Macros for Qt Creator code model

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
6 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    paulf
    wrote on last edited by
    #1

    Is there a way to pass macros to the code model? We use a compiler command line macro to control inlining. Clang code model isn't seeing it, and it's polluting my 'issues' pane. I have the macro in both project.cflags and project.config.

    aha_1980A 1 Reply Last reply
    0
    • P paulf

      Our CMake files contain something like

      set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}  --D INLINE_FUNCTION=''")
      set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}  --D INLINE_FUNCTION='__attribute__((always_inline))'")
      

      So for my debug project I have, in project.config,

      #define  INLINE_FUNCTION ''
      

      In our code we have in our headers things like

      static inline foo(void) INLINE_FUNCTION;
      
      static inline foo(void)
      {
          /* definition of foo */
      }
      

      The code model complains that

      foo.h:123 error: expected function body after function declarator
      

      So I presume that the macro substitution is not being performed.

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @paulf

      Just to be clear: You are using a generic project (https://doc.qt.io/qtcreator/creator-project-generic.html), not a CMake project for Creator (why?).

      What happens if you change the config to #define INLINE_FUNCTION (i.e. empty)?

      Regards

      Qt has to stay free or it will die.

      P 1 Reply Last reply
      0
      • P paulf

        Is there a way to pass macros to the code model? We use a compiler command line macro to control inlining. Clang code model isn't seeing it, and it's polluting my 'issues' pane. I have the macro in both project.cflags and project.config.

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @paulf,

        project.config is the right place. How do you define it?

        Regards

        Qt has to stay free or it will die.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          paulf
          wrote on last edited by paulf
          #3

          Our CMake files contain something like

          set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}  --D INLINE_FUNCTION=''")
          set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}  --D INLINE_FUNCTION='__attribute__((always_inline))'")
          

          So for my debug project I have, in project.config,

          #define  INLINE_FUNCTION ''
          

          In our code we have in our headers things like

          static inline foo(void) INLINE_FUNCTION;
          
          static inline foo(void)
          {
              /* definition of foo */
          }
          

          The code model complains that

          foo.h:123 error: expected function body after function declarator
          

          So I presume that the macro substitution is not being performed.

          aha_1980A 1 Reply Last reply
          0
          • P paulf

            Our CMake files contain something like

            set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}  --D INLINE_FUNCTION=''")
            set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}  --D INLINE_FUNCTION='__attribute__((always_inline))'")
            

            So for my debug project I have, in project.config,

            #define  INLINE_FUNCTION ''
            

            In our code we have in our headers things like

            static inline foo(void) INLINE_FUNCTION;
            
            static inline foo(void)
            {
                /* definition of foo */
            }
            

            The code model complains that

            foo.h:123 error: expected function body after function declarator
            

            So I presume that the macro substitution is not being performed.

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @paulf

            Just to be clear: You are using a generic project (https://doc.qt.io/qtcreator/creator-project-generic.html), not a CMake project for Creator (why?).

            What happens if you change the config to #define INLINE_FUNCTION (i.e. empty)?

            Regards

            Qt has to stay free or it will die.

            P 1 Reply Last reply
            0
            • aha_1980A aha_1980

              @paulf

              Just to be clear: You are using a generic project (https://doc.qt.io/qtcreator/creator-project-generic.html), not a CMake project for Creator (why?).

              What happens if you change the config to #define INLINE_FUNCTION (i.e. empty)?

              Regards

              P Offline
              P Offline
              paulf
              wrote on last edited by
              #5

              @aha_1980

              For the moment I'm using a generic project. Just leaving the define blank seems to work. It's a bit confusing that it doesn't work in the same was as the compiler (where define is implicitly 1).

              I'll give CMake a go as well, it'll be interesting to see if that will cope with our CMake files.

              1 Reply Last reply
              1
              • P Offline
                P Offline
                paulf
                wrote on last edited by
                #6

                Oh well, "Open cmake project" worked about as well as I expected. Creator just terminated. That's more a reflection of our heathrobinson Cmake files.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved