[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
D.2 Coding style
If you plan to contribute code to the Gmsh project, here are some easy rules to make the code easy to read/debug/maintain:
-
Please enable full warnings for your compiler (e.g.
-Wall
withg++
) and don’t commit until there is no warning left. -
Use memory checking tools to detect memory leaks and other nasty memory
problems. For example, you can use
-
Valgrind on Linux:
valgrind --leak-check=yes --show-reachable=yes gmsh file.geo -3
-
GMALLOC on Mac OS X:
(gdb) set env DYLD_INSERT_LIBRARIES /usr/lib/libgmalloc.dylib
-
LIBNJAMD:
export LD_PRELOAD=libnjamd.so kill -USR1
- Purify
- Memprof
- …
-
Valgrind on Linux:
-
always use the
Msg::
class to print information or errors - indent your files (2 spaces) and convert all tabs to spaces
- follow the style used in the existing code when adding something new (spaces after commas, opening braces for functions on a separate line, opening braces for loops and tests on the same line, etc.)
This document was generated on February 9, 2014 using texi2html 5.0.