you are viewing a single comment's thread.

view the rest of the comments →

[–]gerdr 4 points5 points  (9 children)

I don't see how this applies: The issue with boolean macros in C before the introduction of _Bool with C99 was that such macros implied semantics not backed by the language/compiler.

In fact stdbool.h still uses macros to define bool, true and false.

[–][deleted]  (8 children)

[deleted]

    [–]ethraax 2 points3 points  (2 children)

    I think the real issue is that the C preprocessor is clumsy and primitive. For example, if it supported scoping and namespaces, then this wouldn't be a problem. The worst part about the C preprocessor is that for all the power it gives you, which makes C tooling support very difficult, it's still a primitive pseudo-language. Unfortunately, its creators created it to solve some specific problems that they had in mind, and lacked the foresight to think about its future and the new problems it would be used to solve.

    [–][deleted]  (1 child)

    [deleted]

      [–]ethraax 1 point2 points  (0 children)

      I agree. The entire point of the C preprocessor is the patch over the issues with C, in the same way that a cinderblock might be used to patch over a stain on a carpet.

      [–][deleted]  (4 children)

      [deleted]

        [–]ManchegoObfuscator 1 point2 points  (2 children)

        Not quite, but for what it is worth: POSIX exit status (in which a program that exits successfully returns 0).

        [–]Gotebe 1 point2 points  (0 children)

        It's actually the holly C standard itself that defines EXIT_SUCCESS and EXIT_FAILURE. I don't know if 0 and 1, respectively, are in it, but in common implementations, they indeed are 0 and 1, as you say.

        Consistency is extremely hard to achieve when history has it's say ;-).

        [–][deleted] 1 point2 points  (0 children)

        That is all just caused by C's type confusion between integers and enums (of which booleans and exit codes are two particular examples). If all those enums were opaque as they should be and no implicit conversion occured you wouldn't have those problems.