Author Topic: How do add a target to generate cpp output files?  (Read 2840 times)

Offline hanshuckebein

  • Multiple posting newcomer
  • *
  • Posts: 36
How do add a target to generate cpp output files?
« 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?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline sodev

  • Regular
  • ***
  • Posts: 497
Re: How do add a target to generate cpp output files?
« Reply #2 on: February 28, 2019, 08:03:12 pm »
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.

Offline hanshuckebein

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: How do add a target to generate cpp output files?
« Reply #3 on: February 28, 2019, 08:53:54 pm »
> 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?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: How do add a target to generate cpp output files?
« Reply #4 on: February 28, 2019, 09:12:40 pm »
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

Offline hanshuckebein

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: How do add a target to generate cpp output files?
« Reply #5 on: February 28, 2019, 09:52:40 pm »
"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