Browse Source

include order

Former-commit-id: aa8657420b3466b2abff0c701ea14c74c5435cad
Alec Jacobson 9 years ago
parent
commit
11488866ec
1 changed files with 29 additions and 5 deletions
  1. 29 5
      style-guidelines.md

+ 29 - 5
style-guidelines.md

@@ -171,8 +171,8 @@ Eigen and stl. These functions should have the `igl::` namespace.
 
 
 Functions with other dependencies should be placed into
 Functions with other dependencies should be placed into
 appropriate sub-directories (e.g. if `myfunction` depends on tetgen then create
 appropriate sub-directories (e.g. if `myfunction` depends on tetgen then create
-`igl/tetgen/myfunction.h` and `igl/tetgen/myfunction.cpp` and give the function
-the namespace `igl::tetgen::myfunction`.
+`igl/copyleft/tetgen/myfunction.h` and `igl/copyleft/tetgen/myfunction.cpp` and give the function
+the namespace `igl::copyleft::tetgen::myfunction`.
 
 
 ### copyleft subdirectory/namespace 
 ### copyleft subdirectory/namespace 
 
 
@@ -192,11 +192,11 @@ assert(m < n && "m must be less than n");
 
 
 Every header file should be wrapped in an `#ifndef` compiler directive. The
 Every header file should be wrapped in an `#ifndef` compiler directive. The
 name of the guard should be in direct correspondence with the path of the .h
 name of the guard should be in direct correspondence with the path of the .h
-file. For example, `include/igl/tetgen/tetrahedralize.h` should be
+file. For example, `include/igl/copyleft/tetgen/tetrahedralize.h` should be
 
 
 ```cpp
 ```cpp
-#ifndef IGL_TETGEN_TETRAHEDRALIZE_H
-#define IGL_TETGEN_TETRAHEDRALIZE_H
+#ifndef IGL_COPYLEFT_TETGEN_TETRAHEDRALIZE_H
+#define IGL_COPYLEFT_TETGEN_TETRAHEDRALIZE_H
 ...
 ...
 #endif
 #endif
 ```
 ```
@@ -210,6 +210,30 @@ Do not use tabs. Use 2 spaces for each indentation level.
 Limit lines to 80 characters. Break up long lines into many operations (this
 Limit lines to 80 characters. Break up long lines into many operations (this
 also helps performance).
 also helps performance).
 
 
+## Include order
+
+`#include` directives at the top of a .h or .cpp file should be sorted
+according to a simple principle: place headers of files most likely to be
+edited by you first. This means for
+`include/igl/copyleft/tetgen/tetrahedralize.cpp` you might see
+
+```cpp
+// [Includes of headers in this directory]
+#include "tetrahedralize.h"
+#include "mesh_to_tetgenio.h"
+#include "tetgenio_to_tetmesh.h"
+// [Includes of headers in this project]
+#include "../../matrix_to_list.h"
+#include "../../list_to_matrix.h"
+#include "../../boundary_facets.h"
+// [Includes of headers of related projects]
+#include <Eigen/Core>
+// [Includes of headers of standard libraries]
+#include <cassert>
+#include <iostream>
+```
+
 ## Eigen templates
 ## Eigen templates
 
 
 
 
+