Use headers guards. Put the header guard in the first line of the header, before the copyright. Use all-uppercase name for the header guard. Derive the header guard name from the file name, and append _INCLUDED to create a macro name. Example: sql_base.h -> SQL_BASE_INCLUDED.
Include directives shall be first in the file. In class implementation, include the header file with class declaration before all other header files, to make sure that the header is self-sufficient.
Every header file should be self-sufficient in the sense that for a header file my_header.h, the following should compile without errors:
An exception is made for generated files, for example, those generated by Yacc and Lex, since it is not possible to re-write the generators to produce "correct" files.
Copyright © 1997, 2014, Oracle and/or its affiliates. All rights reserved. Legal Notices