It is sometimes overlooked in the heat of programming that a header
file is included multiple times.  Conventionally we use the header
guard macro which prevent recompilation--but it doesn't prevent
reading the whole file.

For GNU C,  C++, and FORTRAN (all of which use GNU cpp) there is a
solution: use a conditional "#pragma once" in each header file.  For
example:

/* header.g */
/* place the following at the beginning of the file: */
#if defined(__GNUC__)
#pragma once
#endif

/* the usual header guard follows...*/
#ifndef HEADER_H
#define HEADER_H

/* code ..... */

#endif /* HEADER_H */
/* EOF */

Ideally such should not be needed, but it seems to me to be a cheap
trick for such a code base as BRL-CAD.

-Tom

Thomas M. Browder, Jr.
Niceville, Florida
USA

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
BRL-CAD Developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to