Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: hanshuckebein on February 28, 2019, 07:31:27 pm
-
I want to add target, which only generates .i files via gcc cpp. The problem is, that CB adds a -c option, which causes gcc to compile the source file.
How to get rid of this -c option?
-
Have you read this page: http://wiki.codeblocks.org/index.php/Adding_support_for_non_C/C%2B%2B_files_to_the_build_system
-
I think thats not what he wants, i think he wants that his c/c++-files don't get compiled but only preprocessed.
You could override the build command for each file, but i guess that is quite some work. To really let a target do this, define a new compiler and change its compile command to not compile but only preprocess and select that compiler for this target.
-
> I think thats not what he wants, i think he wants that his c/c++-files don't get compiled but only preprocessed.
Exactly.
I tried to find this dialog under "...and how things have evolved", but sorry, I couldn't find it in my CB 16.01. This description is very verbous to describe past things, but nothing how to do the job with the new version. Also there is no information on versions of CB - this all but useful…
> You could override the build command for each file, but i guess that is quite some work. To really let a target do this, define a new compiler and change its compile command to not compile but only preprocess and select that compiler for this target.
Where to find a dialog to do this?
-
Settings->Compiler->Copy
give it a new verbose name.
Select it from the drop down menu
In the same dialog select the "Other settings" tab. You probably have to press the ">" button at the right side, to scroll to this tab
Advanced options
Now you can set the compile commands for this compiler... Set it up to generate your .i files..
Close all dialogs with ok
Project->Properties->Build targets->Add->Give it a verbose name
Select the new target on the left->Build options->From the drop down menu at the top select your new defined compiler
Close all dialogs with ok
Select the new target near the build toolbar or via Build->Select target
You probably have to rebuild the project with the Build->Rebuild
-
"Advanced Compiler Options" | "Command line macro": $compiler $options $includes -E $file -o $object
The resulting gcc command is: gcc <options> -c file.c -E bin/file.o
=> since -c is present, file.c gets compiled and not preprocessed only