Skip to content

Commit d7d850e

Browse files
avargitster
authored andcommitted
CodingGuidelines: mention C99 features we can't use
The C99 section of the CodingGuidelines is a good overview of what we can use, but is sorely lacking in what we can't use. Something that comes up occasionally is the portability of %z. Per [1] we couldn't use it for the longest time due to MSVC not supporting it, but nowadays by requiring C99 we rely on the MSVC version that does, but we can't use it yet because a C library that MinGW uses doesn't support it. 1. https://lore.kernel.org/git/[email protected]/ Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 82dd01d commit d7d850e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Documentation/CodingGuidelines

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@ For C programs:
235235
. since late 2021 with 44ba10d6, we have had variables declared in
236236
the for loop "for (int i = 0; i < 10; i++)".
237237

238+
New C99 features that we cannot use yet:
239+
240+
. %z and %zu as a printf() argument for a size_t (the %z being for
241+
the POSIX-specific ssize_t). Instead you should use
242+
printf("%"PRIuMAX, (uintmax_t)v). These days the MSVC version we
243+
rely on supports %z, but the C library used by MinGW does not.
244+
238245
- Variables have to be declared at the beginning of the block, before
239246
the first statement (i.e. -Wdeclaration-after-statement).
240247

0 commit comments

Comments
 (0)