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
Forum Updated to NodeBB v4.3 + New Features

Macros for Qt Creator code model

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
6 Posts 2 Posters 926 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 23 Mar 2020, 17:22 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.

    A 1 Reply Last reply 23 Mar 2020, 17:42
    0
    • P paulf
      24 Mar 2020, 08:19

      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.

      A Offline
      A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on 24 Mar 2020, 09:04 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 24 Mar 2020, 13:34
      0
      • P paulf
        23 Mar 2020, 17:22

        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.

        A Offline
        A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on 23 Mar 2020, 17:42 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 24 Mar 2020, 08:19 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.

          A 1 Reply Last reply 24 Mar 2020, 09:04
          0
          • P paulf
            24 Mar 2020, 08:19

            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.

            A Offline
            A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on 24 Mar 2020, 09:04 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 24 Mar 2020, 13:34
            0
            • A aha_1980
              24 Mar 2020, 09:04

              @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 24 Mar 2020, 13:34 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 24 Mar 2020, 14:06 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

                1/6

                23 Mar 2020, 17:22

                • Login

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