Author Topic: Build doesn't recompile with macro-define #include  (Read 3762 times)

Offline pozzugno

  • Multiple posting newcomer
  • *
  • Posts: 39
Build doesn't recompile with macro-define #include
« 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?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Build doesn't recompile with macro-define #include
« Reply #1 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.
(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 thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Build doesn't recompile with macro-define #include
« Reply #2 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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline pozzugno

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: Build doesn't recompile with macro-define #include
« Reply #3 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?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Build doesn't recompile with macro-define #include
« Reply #4 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline pozzugno

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: Build doesn't recompile with macro-define #include
« Reply #5 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?