File: CodingStyle.md

package info (click to toggle)
knxd 0.14.30-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,644 kB
  • sloc: cpp: 21,518; ansic: 4,859; pascal: 3,728; makefile: 514; sh: 253; ruby: 132; java: 65; python: 40; xml: 15
file content (33 lines) | stat: -rw-r--r-- 951 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# KNXD Coding Style

KNXD is written in C++. It has originally been formatted using "indent",
which unfortunately knows only C but next to nothing about C++, thus some
of the spacing in the code doesn't look at all like idiomatic C++.

Please try to adhere to the formatting of existing code as much as
possible, or at least as much as you're comfortable with. Specifically,
please adhere to the two/four-space indent scheme:

    if (x)
      {
        more_statements;
        more_statements;
      }
    else
      single_statement;

## "#ifdef"s

All "#ifdef" statements should be either

* guard macros (#ifndef foo / #define foo … / #endif)

* conditional on a specific compiler (cf. "#ifdef __gnuc__" in
  src/common/types.h)

* conditional on "HAVE_XXX" as discovered by autoconf.

Operating system specific conditionals are not allowed: they tend
to stop working when you switch compilers, cross-compile, or build
with an alternate libc.