Re:Modern C, Second Edition
by kccqzy on Wednesday September 18, 2019 @04:13PM
(#21009593)
It depends on the perspective. To me and in the codebases I've worked in, the predominant style is "int const" instead of the other way around.
[ Parent
| on HN ]
My perspective is that "const type" order consistently appears in all versions of the ISO C standard and POSIX.
Every major system API I can remember working with that didn't hide const behind a typedef (like Win32's LPCSTR and whatnot) has it const first.
Speaking of Microsoft, though the API's hide const with a typedef, the MSDN samples are predominantly "const char" order.
I've never seen a man page with "int const".
Searching all of the man pages I have installed on an Ubuntu 18 system here (literally grepping through all of /usr/share/man), I found just one with "char const" or "int const". Namely this one:
$ man guestfs-hacking
This contains: int
commandvf (char **stdoutput, char **stderror, unsigned flags,
char const *const *argv)
In the same man page, there are other declarations that have the predominant convention: int
commandrf (char **stdoutput, char **stderror, unsigned flags,
const char *name, ...)
You just worked on some unusual code bases, and are glossing over the language and system API's those code bases depended on, and their respective docs.