-
Notifications
You must be signed in to change notification settings - Fork 128
File Header Structure and Includes
williamfgc edited this page May 4, 2017
·
41 revisions
-
License header: All files start with the ADIOS2 Apache license header, file name, creation date, and author's name. 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 files include guards: all header files must have include guards to prevent 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, file adios2/engine/bp/BPFileWriter.h will contain the following include guards:
#ifndef ADIOS2_ENGINE_BP_BPFILEWRITER_H_ #define ADIOS2_ENGINE_BP_BPFILEWRITER_H_<br><br> //File contents... ... //End of file #endif // end of ADIOS2_ENGINE_BP_BPFILEWRITER_H_
-
Document included headers: 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>;
-
Header includes organization: use the following ordering for the included headers: Example for file ClassName.cpp:
- Corresponding header:
ClassName.h
- POSIX/C headers:
sys/ipc.h, unistd.h
- C++ headers:
map, thread, vector
- External libraries:
zfp.h, bzip2.h
- ADIOS2 headers:
adios2/ADIOSTypes.h, adios2/ADIOSMPI.h
#include "ClassName.h" #include <unistd.h> //key_t #include <sys/ipc.h> //ftok #include <map> #include <thread> #include <vector> #ifdef ADIOS_USE_ZFP #include <zfp.h> #endif #ifdef ADIOS_USE_BZip2 #include <bzip2.h> #endif #include "adios2/ADIOSTypes.h" #include "adios2/ADIOSMPI.h"
- Corresponding header: