-
-
Notifications
You must be signed in to change notification settings - Fork 420
Description
Currently many places in codebase copy around a definition of a bool_t as enum or int; there are few uses of stdbool.h that should have handled the type.
I suppose we have legacy systems to consider that might not have this header yet, so maybe a nut_stdbool.h (similar in purpose and construct to timehead.h and nut_stdint.h) is in order, to streamline this basic type definition and use.
UPDATE: See also, some prior art found:
- Issue Consolidate bool_t definitions into a common header file #31
- Commit zykh@222d6e0 (and likely a sibling in libusb-compat-1.0 branch)
- Also noted in
FTYbranch differences frommaster, see Upstreaming improvements from 42ity/nut fork #1316 - Similar concern about common handling of boolean-ish strings in one implementation, see Consolidate bool string parsing into a common method #2811
- Rename
boolunion member wmnut#11 gives another interesting reminder from @a3a3el :
In C23,
boolhas been changed from a macro defined in<stdbool.h>, which expands to_Bool, to a keyword.
(Further note concerns wmNut code, but it is worth checking other repos including NUT for similar cases; perhaps extendconfigure.acto detect the kind ofbooldefinition a build environemnt has or does not have) Thevarunion defined inwmgeneral.hcontains a member namedbool, which is, therefore, not compatible with C23. The next version of gcc defaults to C23, and so this union member will cause compilation to fail. Rename it toboolean.
- Replace
if (cond) { x = 1; } else { x = 0; }withx = cond;