User forums > Help
LLVM Clang precompiled headers Code::Blocks 20.03
camilocc:
Hi Tim,
Where can I ask to add for this support for Clang precompiled headers at Code::Blocks?
I tried to use "Custom Build" for the framework.h with -emit-pch flag but it didn't work. (I had chosen Compile File and set priority to 0).
It didn't build the .pch file.
Maybe it be because of this CodeBlocks I got at CentOS was built with WGTK3?
Best regards,
Camilo
camilocc:
Hi stahta01,
Yes, I set the framework.h (the file to be precompiled), to be compiled (like headers are not normally selected to be built, by selecting "Compile File" at Framework.h file Properties Dialog). (But not linked).
I also tried to set the Custom Build (at Advanced Tab for framework.h file Properties Dialog).
I tried some combinations of the suggested options at the bottom of Custom Build (written in Red) plus -emit-pch flag.
Also set the priority slider all way to left (0).
When I select Code::Blocks to do the build, only the .cpp is compiled.
Even after Clean Workspace.
The framework.h build step is not run.
Best regards,
Camilo
oBFusCATed:
I guess the steps are like these:
1. select the header, mark it for compilation, edit its command (right click -> properties -> advanced) -> add the emit-pch option
2. add the include-pch option to compiler options (there are chances this would break the compilation of the pch)
3. build
2. step to probably could be replaced by just including the pch in the source.
p.s. even if you report it as a ticket I have zero intention to work on this. I might apply a patch, but I think pch and unity builds are a waste of time and a gimmick.
p.p.s. cb uses pch and builds fine with clang, I'm not sure why this isn't "just works" (tm) style of thing.
p.p.p.s. pch in cb is wasting me so much time when I'm iterating on something...
camilocc:
I could make it work at Ubuntu 19.10 with Code::Blocks 20.03 from the ppa:codeblocks-dev/release
For C++ project.
for framework.h to produce precompiled header
1. Select at Main Project Options the Precompiled Header Strategy : Generate PCH alongside original header (default) (don't know if this flag actually currently makes any difference for this).
2. Create framework.cpp that includes just framework.h.
3. Select at framework.cpp properties for it just to be built (not linked) and lower priority to 0 to make it build firstly.
4. At framework.cpp properties > advanced tab, check custom build and set it to:
$compiler $options $includes -x c++-header framework.h -o framework.h.gch
5. For the project, set the extra compiler option:
-include "framework.h"
If this option is not set, clang++ won't use the precompiled header even if its present at the folder or even if it is included inside the cpp explicitly.
I couldn't set these properties I had set for framework.cpp at framework.h. Code::Blocks seems not to build it when using LLVM CLang compiler (it shows not dimmed at the project tree, but it still doesn't built.)
And the -emit-pch seems to be a clang option for another environment or situation, not for this C++ thing.
I am facing another problem now. The C11 flag (for clang) and C++17 (for clang++) keep offending each other on LLVM Clang projects with blend of C++ and C files. This used to happen with GCC compiler but it was fixed. Now it seems to be a problem with LLVM Clang compiler (at Ubuntu Linux, at least). (I think it may happen because the -include "framework.h" is there (in the C files (clang)) and the precompiled-header was compiled with C++17 options for C++.)
Best regards,
Camilo
Navigation
[0] Message Index
[*] Previous page
Go to full version