1 # Guidelines for Development/Contributing {#HACKING}
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).
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.
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/`:
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)
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.
19 [llvmwin]:http://llvm.org/builds/
24 - Macros, constants, and enum values are all caps.
26 - The "body" of a type name is in CamelCase.
28 - Functions are camelCase except for the first character.
30 - No Hungarian notation - the closest we come is `m_whatever` for
31 private class members.
33 - Be consistent and match surrounding code.
35 ### C Code (APIs only)
36 - Functions should be prefixed by `osvr` - this means a function is
37 named like `osvrMyFunction`
39 - Types (typedefs, structs) should be prefixed by `OSVR_` - this means a
40 type is named like `OSVR_MyType`
42 - Macros, constants, and enum values should also be prefixed by `OSVR_`
45 - Use lowercase namespaces such as `osvr`, nested appropriately as required.
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.