7

After reading about the pimpl idiom I was horrified!

Isn't there a tool out there that can inspect a .h/.cpp file and deduce what dependencies could be waivered?

Jonathan
  • 84,911
  • 94
  • 244
  • 345
  • No there isn't. The only "tool" who can reliably tell which dependencies are required is the c++ compiler itself... Gave Daniel a +1 since his statement exactly matches my opinion. – Paul Michalik May 04 '11 at 10:15

3 Answers3

2

Sorry, but no there isn't. C++ still relies on preprocessing source files, very mechanical. Large-scale C++ development is all about reducing the dependencies. In my opinion, C++ is simply not suitable for those kinds of tasks.

Daniel Lidström
  • 7,890
  • 1
  • 24
  • 33
2

Does precompiling the headers not solve many of these horrors. Both MS and g++ support these now.

Tom
  • 5,019
  • 1
  • 26
  • 43
  • Do you have a reference for this? – Jonathan Dec 04 '10 at 16:25
  • 1
    @Jonathan For gcc: http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html, for MS: http://msdn.microsoft.com/en-us/library/szfdksca.aspx – Tom Dec 06 '10 at 13:26
  • @Tom: no, actually they solve only one problem: reducing *complete recompilation* time. Moreover, if your precompiled headers include changeable headers, you are misusing them. – Roman L Jan 04 '11 at 15:31
  • @7vies You are of course right. I seem to remember reading a post on the boost build forums for trying to reduce the rereading of the boost header files. There was a mixed response as to how beneficial it was if I remember. I tried to find the link but I can't locate it - if anyone comes across it feel welcome to edit my answer to add it. – Tom Jan 06 '11 at 10:59
  • @Tom: boost libs or any other stable library are of course good candidates for precompiled headers, but I don't see how this can help with pimpl-related horrors – Roman L Jan 06 '11 at 13:26
  • @7vies I mention the boost build system bjam (not the boost libraries themselves) only because I believe they considered trying to reduce the *reading* of the headers. Your comments on pre-compilation are correct, they reminded me of an attempt to remedy this. – Tom Jan 06 '11 at 14:30
0

Static code inspection for C++ is a nightmare, because of its syntax and macro preprocessor, I doubt there are tools like the one you describe.

If it existed, what would you expect from it? Would you like it to refactor/rewrite code for you? Adding and/or removing what?

Sounds like a daunting task to me.

Simone
  • 10,912
  • 1
  • 26
  • 39
  • I would expect it to suggest which inclusions could be removed, which could be replaced by forward statements and which must be kept – Jonathan Nov 26 '10 at 00:20