Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: pozzugno on August 07, 2012, 12:42:19 pm

Title: Build doesn't recompile with macro-define #include
Post by: pozzugno on August 07, 2012, 12:42:19 pm
Code: "main.c"
#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:
Code
#include "test.h"
it works.

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

Is there a solution to this problem?
Title: Re: Build doesn't recompile with macro-define #include
Post by: oBFusCATed on August 07, 2012, 01:07:19 pm
Yes, don't use the macro hack  :P

The other option is to patch depslib to parse this correctly.
Title: Re: Build doesn't recompile with macro-define #include
Post by: thomas on August 07, 2012, 01:27:05 pm
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.
Title: Re: Build doesn't recompile with macro-define #include
Post by: pozzugno on August 07, 2012, 03:36:33 pm
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?
Title: Re: Build doesn't recompile with macro-define #include
Post by: MortenMacFly on August 07, 2012, 05:06:37 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.
Title: Re: Build doesn't recompile with macro-define #include
Post by: pozzugno on August 07, 2012, 05:32:23 pm
Quote
Using 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?