GSI Forum
GSI Helmholtzzentrum für Schwerionenforschung

Home » PANDA » PandaRoot » Bugs, Fixes, Releases » compilation of macros
Re: compilation of macros [message #9848 is a reply to message #9840] Thu, 03 December 2009 09:48 Go to previous messageGo to previous message
Florian Uhlig is currently offline  Florian Uhlig
Messages: 424
Registered: May 2007
first-grade participant
From: *gsi.de
Hi Mathias

Quote:

did I understood correctly, that the order of #include statements has some effect?? This must be a joke. If not, what about cleaning up all header files?



It is not a joke. This is real life and a well known problem.

If all the header files would be both self sufficient and idempotent then the order would not matter. As you can see with
this problem if they are not you can have problems.
I add below a part from Bruce Eckels book "Thinking in C++, Volume 1" which hopefully makes the point more clear.

Quote:


Order of header inclusion

Headers are included from "the most specific to the most general." That is, any header files in the local directory are included first, then any of my own "tool" headers such as require.h or purge.h, then any third-party library headers, then the standard C++ library headers, and finally the C library headers.

The justification for this comes from John Lakos in Large-Scale C++ Software Design (Addison-Wesley, 1996):


Latent usage errors can be avoided by ensuring that the .h file of a component parses by itself -- without externally-provided declarations or definitions... Including the .h file as the very first line of the .c file ensures that no critical piece of information intrinsic to the physical interface of the component is missing from the .h file (or, if there is, that you will find out about it as soon as you try to compile the .c file).


If the order of header inclusion goes "from most specific to most general," then it's more likely that if your header doesn't parse by itself, you'll find out about it sooner and prevent annoyances down the road.



By the way the PndDrc.h file was the first header included in PndDrc.cxx until 22.07.09. At that point the order was changed, probaly to overcome the problem in the header file which came in at the same time.

To clean all header files would be a good idea but i fear that it will not help. We did this some time ago and now it is again a mess.

Ciao

Florian
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: TPC geant4
Next Topic: Small bug with cmake/config.sh
Goto Forum:
  


Current Time: Wed Aug 17 05:58:58 CEST 2022

Total time taken to generate the page: 0.01381 seconds