MySQL 8.0.40
Source Code Documentation
Header Files
  • Use header guards. Put the header guard in the first line of the header, before the copyright. Use an all-uppercase name for the header guard. Derive the header guard name from the file base name, and append _INCLUDED to create a macro name. Example: sql_show.h -> SQL_SHOW_INCLUDED.
  • Include directives shall be first in the file. In a class implementation, include the header file containing the class declaration before all other header files, to ensure 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:
#include "my_header.h"

An exception is made for generated files; for example, those generated by Yacc and Lex, because it is not possible to rewrite the generators to produce "correct" files.