-
Notifications
You must be signed in to change notification settings - Fork 128
File Header Structure and Includes
williamfgc edited this page May 1, 2017
·
41 revisions
-
License header: All files start with the ADIOS2 Apache license header, file name, creation date, and author. Contact information is encouraged.
/** * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * * MyClass.h * * Created on: April 27, 2017 * Author: Mark Alexander Godoy [email protected] */
-
Header include organization: Example for file ClassName.cpp :
- Corresponding header: ClassName.h
- System C/POSIX Headers e.g. unistd.h, sys/ipc.h
- C++ versions of system C headers e.g. cstdlib, cstring
- System C++ headers e.g. vector, map
- Other library headers e.g. boost, zfp, bzip2, thrust
- Other headers from this library e.g "adiosFunctions.h"
- Example:
#include "ClassName.h"
#include <unistd.h> // write, close #include <sys/ipc.h> // key_t
#include <vector> #include <new> // std::bad_alloc
#include <bzip2.h> #include <zfp.h>
#include "adiosFunctions.h" // IsLittleEndian
-
Include guards: all headers must have include guards to prevents name conflict. These are place right after the license and at the end of the file. The adopted format includes the relative path in ADIOS. For example, adios2/engine/bp/BPFileWriter.h will contain the following include guards:
#ifndef ADIOS2_ENGINE_BP_BPFILEWRITER_H_ #define ADIOS2_ENGINE_BP_BPFILEWRITER_H_
//File contents... ...//End of file #endif // end of ADIOS2_ENGINE_BP_BPFILEWRITER_H_
-
Include documentation: list header components used in the code if header is not self-explanatory
- Example:
//vector and map are self-explanatory, no comment needed
#include <vector>
#include <utility> //std::pair
#include <stdexcept> //std::invalid_argument
#include <map>