Question

I have a problem with code completion in Qt Creator. I have a precompiled header named OgreHeaders.h. I am building with clang using qmake mkspec unsupported/linux-clang. My project builds but when i edit it I don't get any code hints. I think this is because my precompiled header is included using -include-pch compiler option, not #include directive. So Qt Creator code model doesn't even find it. I had an idea about wrapping the header in #ifdefs or #ifndefs so it would parse it but not compile.

#ifdef PCH
#include <OgreHeaders.h>
#endif

I need to somehow #define PCH in Qt Creator code model, but not in the compiler's one. Or do the reverse. I tried using QMAKE_CXX_FLAGS and DEFINES, but Qt Creator picks them up.

I saw this article about integraton. At the bottom of the article is says:

When you go to the “Projects” mode, you will see an extra tab with “Code Completion Settings”, where you can select a “custom” header. When selecting this option, the code-model will use that header as a cache, but the compiler will not use it.

I don't have that option in my Qt Creator(2.8.0). Any ideas how to workaround this issue or I need to build Qt Creator with clang integration from git?

Was it helpful?

Solution

Put either

#define PCH

or

#undef PCH

to PROJECT_NAME.config file in your project's root directory, where PROJECT_NAME is name of your project in Qt Creator -- just like PROJECT_NAME.files and PROJECT_NAME.includes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top