User forums > Nightly builds

The 10 May 2007 build will NOT be out. (developers please read this)

<< < (2/4) > >>

byo:
Hmm, I was thinking lately about writing some tool that would add such missing headers automatically.

It's really easy task. It would base on fact that certain identifiers used in sources require certain header files. So when there's for example GetMessageManager or DebugLog used anywhere, it would notify that messagemanager.h is needed. After generating list of headers it could scan for all #include directives and add missing ones. Of course it would be not an universal tool but could work perfectly in case of C::B stuff (for both missing sdk and wx headers).

I think no more than few hours to make core tool. Maybe some more time to create Ident -> header bindings., but that doesn't have to be complite from the very beginning. What do you think about that?

I could sacrifice one night so Killerbot would be able to sleep well all the time without having nightmares about missing headers 8)

Regards
   BYO

killerbot:
well I don't say don't use pch. They have some advantage, they can speed up compilation, certainly when one is using a 'stable' sdk. The sdk of CB is not stable yet so because of that sometimes pch make the compilation longer, because there's a very high coupling of unrelated things in that pch file. On the other hand it introduces broken builds way to many, why because one adds an extra statement with whatever objects or types, hit compile .... it compiles. Cool, yes, but it compiled because most of the developers are using the pch build system or they environment automatically does the pch way, but then when building on a non pch build environment, the build is broken because the correct headers were not added for those just added statements.

My personal feeling is that pch makes programmers a bit lazy and the programmers forget to think about how headers actually (should) work. How would I say it, it gives a sense of false safety.

The basic line is : use headers correctly --> then it builds for non pch, and if you also want to support pch well then you add some special things to your file.
I once have written an article on correct use, I will review it once more tjhis weekend and publish it, I think it will make a whole bunch of things more clear.

Synopsis : pch are not bad, they need to be used correctly in ADDITION to the normal way of header inclusion, so one gets correct and portable code. ;-)

MortenMacFly:

--- Quote from: killerbot on May 11, 2007, 08:00:35 am ---My personal feeling is that pch makes programmers a bit lazy and the programmers forget to think about how headers actually (should) work. How would I say it, it gives a sense of false safety.

--- End quote ---
I've another solution besides Byo's beautiful idea (which I think is great):
I'm about to submit an update to the envvars plugin where I have simply added another target "no_pch". In there I do *not* define the *PRECOMP stuff but simply define NOPCH. Thus if this target builds it's most likely that it will immediately work on other machines without PCH (Linux), too. I've detected quite some PCH issues using this method. Once I have submitted you can have a look at it... 8)

With regards, Morten.

byo:
Ok, as promised, tool that can help fixing missing headers. Sources are in attachment (project file may still need some tuning since I've not updated it to use $(WX_SUFFIX) etc. stuff).

I've added most of identifiers from C::B so it should work in most critical situations.

The plugin itself is very "dumb". For example, when processing any file, it won't process included files and check what stuff they include. So generally, when it process cpp file and some headers are in corresponsing h file, all those headers will probably be added into cpp.

As a result, the tool adds missing includes at the beginning of file, before any previous content (that was easiest to implement ;) ) surrounding it with // *** ADDED BY HEADER FIXUP ***  and // *** END *** comments so they can be quickly found by Search In Files.

I have tested it on wxSmith and it looks like it's working, but of courseback-up your files before using it ;).

BTW. I don't provice cbplugin file because there's some binary incompatibility between my wx and the one used in nightlies.

BYO

[attachment deleted by admin]

MortenMacFly:
Thanks Byo, as we have seen here: http://forums.codeblocks.org/index.php/topic,5903.msg45142.html#msg45142 my attempt was far from being perfect anyway... :cry:
With regards, Morten.

Edit: Wohooo! Looks great! Have tested in on some of the plugins and (in fact) discovered missing includes. As you said there are some header included twice then but it's easy to remove the duplicates afterwards. Much easier than searching for the header files missing. Great work! 8)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version