News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Build doesn't recompile with macro-define #include

Started by pozzugno, August 07, 2012, 12:42:19 PM

Previous topic - Next topic

pozzugno

Code ("main.c") Select

#define INC_FILE "test.h"
#include INC_FILE


If I build the project, change something in test.h and re-build, C::B doesn't recompile.
It thinks all dependecies of main.c are satisfied. It is not able to consider test.h a dependecy for main.c, because it is a macro-replaced include file.
If I write:
#include "test.h"
it works.

Consider that I already added test.h file in the project.

Is there a solution to this problem?

oBFusCATed

Yes, don't use the macro hack  :P

The other option is to patch depslib to parse this correctly.
(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!]

thomas

Patching depslib may be much harder than it sounds, though. At least, in a portable, compiler-independent way.

It is not defined by the C standard how string concatenation or generally evaluation of macros within <> is implemented.
So, at best, one would be able to implement single-macro-expanding-to-single-string-literal substitution.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

pozzugno

Ok, it seems C::B is not able to automatically find include dependecies when the file included is a macro.

Is there the possibility to add this dependency manually? Can I say to C::B that main.c depends from the content of test.h too?

MortenMacFly

Quote from: pozzugno on August 07, 2012, 03:36:33 PM
Is there the possibility to add this dependency manually? Can I say to C::B that main.c depends from the content of test.h too?
Using scripting as a pre-build step, yes.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

pozzugno

QuoteUsing scripting as a pre-build step, yes.
I'm sorry, can you detail this point? Should I change the project to a custom makefile? What is the pre-build step to do?