Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » CPP file dependency
CPP file dependency [message #33858] Mon, 19 September 2011 19:30 Go to next message
raxvan is currently offline  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 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 #33863 is a reply to message #33858] Mon, 19 September 2011 23:23 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
raxvan wrote on Mon, 19 September 2011 13:30


In what way is TheIde doing this?



It scans through files to gather #include dependencies...

Mirek
Re: CPP file dependency [message #33871 is a reply to message #33860] Tue, 20 September 2011 12:04 Go to previous messageGo to next message
raxvan is currently offline  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 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 #33874 is a reply to message #33858] Tue, 20 September 2011 13:31 Go to previous messageGo to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
I need a tool to safely optimally construct the dependency tree. I found http://code.google.com/p/include-what-you-use/ but i'm thinking it is two complex. An easier solution is to just simply scan the file for #include and for the macro hack just to ignore it.

Raxvan


92b48bf94855483bb4cec8bcc8c0c933

[Updated on: Tue, 20 September 2011 13:58]

Report message to a moderator

Re: CPP file dependency [message #33876 is a reply to message #33874] Tue, 20 September 2011 14:47 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 #33891 is a reply to message #33872] Thu, 22 September 2011 09:36 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
dolik.rce wrote on Tue, 20 September 2011 06: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...



Actually, the code used to check for dependencies accounts for macros quite well. Otherwise we could not use #include LAYOUTFILE etc... Smile

Mirek
Re: CPP file dependency [message #33892 is a reply to message #33891] Thu, 22 September 2011 10:57 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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... Smile

Mirek

Oups, my mistake then Smile Sorry for underestimating TheIDE.

Honza
Previous Topic: Multiple Layouts
Next Topic: NTL_MOVEABLE and other namespaces
Goto Forum:
  


Current Time: Sat Apr 27 22:25:57 CEST 2024

Total time taken to generate the page: 0.98128 seconds