|
|
Home » Community » Newbie corner » CPP file dependency
CPP file dependency [message #33858] |
Mon, 19 September 2011 19:30 |
raxvan
Messages: 60 Registered: December 2009
|
Member |
|
|
Hello,
If you have a C++ project and change one file how do you detect all the dependences to build the correct number of Cpp files affected by your change?
In what way is TheIde doing this?
Thanks,
Raxvan.
92b48bf94855483bb4cec8bcc8c0c933
|
|
|
Re: CPP file dependency [message #33860 is a reply to message #33858] |
Mon, 19 September 2011 21:28 |
|
Hi Raxvan
If you change a .cpp file, only this single file needs to be rebuild (there are some exceptions, when you use macros heavily, but that is ignored by theide). If you use BLITZ then you might need to recompile the entire "blitz batch" in case that the file you just changed was part of it in the last rebuild.
If you change an .h file, theide will rebuild all .c and .cpp files that include this file. Also files included recursively (i.e. through other .h files) are rebuild. Again, if the "blitz batch" contents change or if any of the files in it includes the changed .h file, then it will be rebuild.
I think these are the basic rules that are used in theide. Does that answer your question sufficiently?
Best regards,
Honza
|
|
|
|
Re: CPP file dependency [message #33871 is a reply to message #33860] |
Tue, 20 September 2011 12:04 |
raxvan
Messages: 60 Registered: December 2009
|
Member |
|
|
dolik.rce wrote on Mon, 19 September 2011 21:28 | Hi Raxvan
If you change a .cpp file, only this single file needs to be rebuild (there are some exceptions, when you use macros heavily, but that is ignored by theide). If you use BLITZ then you might need to recompile the entire "blitz batch" in case that the file you just changed was part of it in the last rebuild.
If you change an .h file, theide will rebuild all .c and .cpp files that include this file. Also files included recursively (i.e. through other .h files) are rebuild. Again, if the "blitz batch" contents change or if any of the files in it includes the changed .h file, then it will be rebuild.
I think these are the basic rules that are used in theide. Does that answer your question sufficiently?
Best regards,
Honza
|
Thanks for the reply, i was interested if an external tool is used or the dependency checker is build in house.
In theide, is it safe if i use macro magic like #include MY_FILE and MY_FILE is defined in some other place? How do you scan then for dependencies without implementing a full preprocessor? This is basically my initial problem. How to solve a dependency if "#include MY_FILE" is used.
Raxvan.
92b48bf94855483bb4cec8bcc8c0c933
|
|
|
Re: CPP file dependency [message #33872 is a reply to message #33871] |
Tue, 20 September 2011 12:53 |
|
raxvan wrote on Tue, 20 September 2011 12:04 | In theide, is it safe if i use macro magic like #include MY_FILE and MY_FILE is defined in some other place? How do you scan then for dependencies without implementing a full preprocessor? This is basically my initial problem. How to solve a dependency if "#include MY_FILE" is used.
|
Nope, as of now TheIDE doesn't understand macros very well, so this is not really safe. On POSIX platforms you could use "touch" as custom build step to force update of the files with the #include, but that is not portable and in some cases it would result into rebuilding everything all the time...
If you know that the definition of MY_FILE will not change too often you can ignore it, but be sure to use "Clean package" after each such change. What exactly are you trying to achieve? Maybe we can try to find some other solution?
Honza
|
|
|
|
Re: CPP file dependency [message #33876 is a reply to message #33874] |
Tue, 20 September 2011 14:47 |
|
If that is all you want than you might want to look at Doxygen, which can generate inclusion graphs if instructed to. Also writing simple script that uses graphviz should be simple - I wrote similar thing for Upp packages some time ago.
Also "g++ -H ..." outputs the entire include hierarchy - you could simply parse it and visualize in other tool, e.g. in already mentioned graphviz. Looking at -M*, -d* and -E options might be of some help as well...
Honza
|
|
|
|
Re: CPP file dependency [message #33892 is a reply to message #33891] |
Thu, 22 September 2011 10:57 |
|
mirek wrote on Thu, 22 September 2011 09:36 | Actually, the code used to check for dependencies accounts for macros quite well. Otherwise we could not use #include LAYOUTFILE etc...
Mirek
|
Oups, my mistake then Sorry for underestimating TheIDE.
Honza
|
|
|
Goto Forum:
Current Time: Sat Apr 27 22:25:57 CEST 2024
Total time taken to generate the page: 0.98128 seconds
|
|
|