Code::Blocks

User forums => Using Code::Blocks => Topic started by: pozzugno on February 27, 2018, 03:36:41 pm

Title: #include MACRO, C::B can't detect dependency
Post by: pozzugno on February 27, 2018, 03:36:41 pm
I have a source file similar to this:

#include "opt.h"
#include INCLUDE_FILENAME


In #include <opt.h> there's something similar to:

#include "user_opt.h"
#ifndef INCLUDE_FILENAME
#  define INCLUDE_FILENAME   "include.h"
#endif


It seems C::B isn't able to detect that .c file depends on include.h too. If I change something in "include.h" only, the build process doesn't anything.
Title: Re: #include MACRO, C::B can't detect dependency
Post by: ollydbg on February 27, 2018, 03:47:17 pm
You are correct, that is a limitation in our compiler plugin. You can have a look at the Code::Blocks' source code to understand how the dependency is calculated. It is in the folder src\plugins\compilergcc\depslib. Can you find a better way to do it?
Title: Re: #include MACRO, C::B can't detect dependency
Post by: pozzugno on February 27, 2018, 04:03:05 pm
Why not add a setting with a command that creates a .depend file that C::B will look during building?
I think many compilers have an option to create a dependecy file that is completely correct.
Title: Re: #include MACRO, C::B can't detect dependency
Post by: stahta01 on February 28, 2018, 01:41:01 am
I am guessing external dependency in code::blocks would not do what you want; but, did you try it to be sure?

Edit: I just recalled external dependency is a linker dependency; and, you likely need an compiler dependency.

Tim S.
Title: Re: #include MACRO, C::B can't detect dependency
Post by: stahta01 on February 28, 2018, 02:47:17 am
You are correct, that is a limitation in our compiler plugin. You can have a look at the Code::Blocks' source code to understand how the dependency is calculated. It is in the folder src\plugins\compilergcc\depslib. Can you find a better way to do it?

So for, I have found "plugins\compilergcc\directcommands.cpp" tends to be the file that calls the depslib functions.

Tim S.
Title: Re: #include MACRO, C::B can't detect dependency
Post by: ollydbg on February 28, 2018, 03:29:26 am
You are correct, that is a limitation in our compiler plugin. You can have a look at the Code::Blocks' source code to understand how the dependency is calculated. It is in the folder src\plugins\compilergcc\depslib. Can you find a better way to do it?

So for, I have found "plugins\compilergcc\directcommands.cpp" tends to be the file that calls the depslib functions.

Tim S.
Correct, if I remember correctly, the depslib just scan each file for some pattern like
Code: [Select]
#include <xxx.h>
or
#include "xxx.h"
And put the xxx.h as the dependency of the current file. It does not use the preprocessor to handle all the sources.