Solved Macros for Qt Creator code model
-
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.
-
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
-
-
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.
-
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
-
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.
-
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.