mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
docs: document we use C11 with GNU extensions now
Follow-up for: #22711
This commit is contained in:
parent
43c893e73e
commit
40f55f6998
@ -81,6 +81,19 @@ SPDX-License-Identifier: LGPL-2.1-or-later
|
|||||||
|
|
||||||
## Code Organization and Semantics
|
## Code Organization and Semantics
|
||||||
|
|
||||||
|
- For our codebase we intend to use ISO C11 *with* GNU extensions (aka
|
||||||
|
"gnu11"). Public APIs (i.e. those we expose via `libsystemd.so`
|
||||||
|
i.e. `systemd/sd-*.h`) should only use ISO C89 however (with a very limited
|
||||||
|
set of conservative and common extensions, such as fixed size integer types
|
||||||
|
from `<inttypes.h>`), so that we don't force consuming programs into C11
|
||||||
|
mode. (This discrepancy in particular means one thing: internally we use C99
|
||||||
|
`bool` booleans, externally C89-compatible `int` booleans which generally
|
||||||
|
have different size in memory and slightly different semantics, also see
|
||||||
|
below.) Both for internal and external code it's OK to use even newer
|
||||||
|
features and GCC extension than "gnu11", as long as there's reasonable
|
||||||
|
fallback #ifdeffery in place to ensure compatibility is retained with older
|
||||||
|
compilers.
|
||||||
|
|
||||||
- Please name structures in `PascalCase` (with exceptions, such as public API
|
- Please name structures in `PascalCase` (with exceptions, such as public API
|
||||||
structs), variables and functions in `snake_case`.
|
structs), variables and functions in `snake_case`.
|
||||||
|
|
||||||
@ -491,7 +504,8 @@ SPDX-License-Identifier: LGPL-2.1-or-later
|
|||||||
|
|
||||||
- Use the bool type for booleans, not integers. One exception: in public
|
- Use the bool type for booleans, not integers. One exception: in public
|
||||||
headers (i.e those in `src/systemd/sd-*.h`) use integers after all, as `bool`
|
headers (i.e those in `src/systemd/sd-*.h`) use integers after all, as `bool`
|
||||||
is C99 and in our public APIs we try to stick to C89 (with a few extensions).
|
is C99 and in our public APIs we try to stick to C89 (with a few extensions;
|
||||||
|
also see above).
|
||||||
|
|
||||||
## Deadlocks
|
## Deadlocks
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user