News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

#include MACRO, C::B can't detect dependency

Started by pozzugno, February 27, 2018, 03:36:41 PM

Previous topic - Next topic

pozzugno

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.

ollydbg

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?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

pozzugno

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.

stahta01

#3
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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

stahta01

Quote from: 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?

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

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

ollydbg

Quote from: stahta01 on February 28, 2018, 02:47:17 AM
Quote from: 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?

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

#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.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.