[chbot] C Coding Style

Volker Kuhlmann list0570 at paradise.net.nz
Fri Sep 23 04:17:04 BST 2016


On Fri 23 Sep 2016 09:01:09 NZST +1200, Peter Harris wrote:

> #define INTERESTING_THRESHOLD 45
> #define STEP_SIZE                            5

The example was for the braces, not the constants...

Although the question was for C, I'd like to point out that for C++
people shuld forget as much as possible that #define exists because it
is (in most cases) no longer necessary. Use const instead, or in a
class, static const. That way you're not circumventing the type safety
system. Both are treated by the compiler as literal constants and
inlined, so the resulting binary is identical. At least until you take
the address of one of them, then the compiler is forced to allocate
actual memory space.

> IPersonallyFindCamelCapsToBeAnApallingAffrontToComprehesibility
> and_find_the_lower_case_underscore_format_to_be_more_legible

Agreed. It screws up acronyms too. But the nice thing about all the
coding styles is that you can pick which one you like best...

Volker

-- 
Volker Kuhlmann
http://volker.top.geek.nz/	Please do not CC list postings to me.



More information about the Chchrobotics mailing list