![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
13.5 Coding conventions
When you try to read the source it might be helpful to know about a few conventions I try to follow. This concerns mostly the names and spelling of variables. And while I try to be consistent unfortunately I don't always follow my own rules all of the time and thus later have to try to to correct these mistakes. I can't promise that I am always successful in this endeavor.
Local variables with function scope should always have all lower case,
i.e. num_points
. For local variables with file scope (i.e.
variables that are global to a whole C file but not further) I tend
to use an upper case for the very first character of the name and all others
in lower case, i.e. Child_return_status
. Truely global variables
(there are more than I am happy with but it's basically impossible to throw
out all of them) mostly consist of more than a single word, where I use an
underscore character between the words, and have each of the words start
with an upper case letter, i.e. Function_Names
. Sometimes that
rule gets a bit loosened up when one of the words is an acronym, where I
then use all upper case characters for the word.
When I use typedef
'ed types I use a similar convention as for global
variables but append the suffix _T
to the end of the name to make them
stick out, like in GUI_Stuff_T
. For #define
'd constants I try
to use all upper case, e.g. NUM_CHANNEL_NAMES
- the same holds for
enumerated values.
With a few exceptions function names are always in all lower case.
Of course, these conventions only hold for my own variables etc. When
I use symbols from libraries I have to use what I get, so e.g.
XPoint
is some typedef
'ed type from X, even though it
looks a bit like a global variable. But I didn't want to go as far as
redefining everything else because it would make things unreasonably
difficult to read for people with experience with the other libraries.
![]() |
![]() |
![]() |
![]() |
![]() |
This document was generated by Jens Thoms Toerring on September 6, 2017 using texi2html 1.82.