User forums > Using Code::Blocks

Making the creation of a cpp file dependand of a .h

(1/2) > >>

xanatose:
I have a cpp file that want to create from a header every time the header changes.

I found that by changing the precompiled headers rule build to be a custom build I can do this. But the way is not perfect as the
file will be recreated on every build. Since I found no way of changing the expected output file for precompile headers.

Is there a way to recreate a cpp file from a header every time the header changes without using a custom build file?

thomas:
I am almost inclined to say: no. Not unless you do some nasty things, at least.

You might be lucky, maybe... if you make a separate build target for just this one header, and try to fool the compiler using the -c, -x and -o flags in "extra options".
Something like  -c -x c++ -o $(file_name).cpp might possibly do... not sure.

thomas:
Oi! Stop!   -c isn't good, you probably want -E.

You want the preprocessor to run, and have that output as cpp file, right?
So I guess this is what you need.

xanatose:
Actually I am creating the cpp from the header using an internal tool.

Basically what I need is that the cpp is remade every time the header changes.
O well, I can always use a custom make file.  Thanks anyway.

Ceniza:
What about marking the header file for compilation and adding a custom build command that calls the internal tool? I haven't tried it myself, but I think it can be done.

Navigation

[0] Message Index

[#] Next page

Go to full version