OSVR-Core  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
HACKING.md
1 # Guidelines for Development/Contributing {#HACKING}
2 
3 Please use `clang-format` to keep the code tidy.
4 The `.clang-format` config file is in the root of the repository.
5 We're basically using the LLVM style, except with 4-space indentation, inner namespace indentation, and auto C++ detection (since turning on C++11 in `clang-format` sometimes makes things not work in less-compelling compilers).
6 
7 The `git clang-format` functionality, which runs `clang-format` only on staged changes in a Git repo, is a good way to keep your changes clean while being careful to not change other files because of some difference in clang version, etc.
8 
9 If you're using Windows, please install a recent [llvm/clang binary][llvmwin], and choose to add the directory to the path. (Makes it easier.)
10 If you've got a non-Express version of Visual Studio, you might also want the clang-format plugin.
11 In either case, there are a pair of scripts in `/devtools/`:
12 
13 - `format-project.sh` runs `clang-format` in place using unix `find` to hopefully grab every file.
14  Windows users need Git for Windows installed and handling `.sh` files to run this.
15  (A default install will do that, IIRC)
16 
17 - `format-file.cmd` runs `clang-format` in place on whatever file or files you drop on it - useful if you want some other code to also look in the same style.
18 
19 [llvmwin]:http://llvm.org/builds/
20 
21 ## Naming Conventions
22 
23 ### General
24 - Macros, constants, and enum values are all caps.
25 
26 - The "body" of a type name is in CamelCase.
27 
28 - Functions are camelCase except for the first character.
29 
30 - No Hungarian notation - the closest we come is `m_whatever` for
31  private class members.
32 
33 - Be consistent and match surrounding code.
34 
35 ### C Code (APIs only)
36 - Functions should be prefixed by `osvr` - this means a function is
37  named like `osvrMyFunction`
38 
39 - Types (typedefs, structs) should be prefixed by `OSVR_` - this means a
40  type is named like `OSVR_MyType`
41 
42 - Macros, constants, and enum values should also be prefixed by `OSVR_`
43 
44 ### C++ Code
45 - Use lowercase namespaces such as `osvr`, nested appropriately as required.
46 
47 - Do not add prefixes (`C`, `I`, `osvr`, `OSVR`, etc) to the beginning
48  of types or functions - those are either Hungarian notation or made
49  redundant by C++'s support for namespaces.