News for hackers. Stuff that matters.
Re:No Us Without You: elifdef and elifndef by ramshorns on Monday March 15, 2021 @01:04PM (#26468520)
Why does the C preprocessor need the #elif syntax at all? C doesn't have it, it just achieves "else if" by embedding the second if statement inside the else clause. But maybe that wouldn't work in the preprocessor?

    #if FOO
        foo();
    #elif BAR
        bar();
    #endif

    #if FOO
        foo();
    #else
        #if BAR
            bar();
        #endif
    #endif
I guess it works but it's clunkier.
Re:No Us Without You: elifdef and elifndef by jomar on Monday March 15, 2021 @01:35PM (#26468949)
For the same reason as in other languages (e.g., Perl, bash) with (effectively, in Perl's case) an explicit end-if keyword: so that you don't need a whole bunch of #endifs at the end of your conditional, one for each #if or #else … #if.

C itself doesn't need this, because you can write `else if …` without needing to put another layer of braces around the subordinate `if` statement.

Re:No Us Without You: elifdef and elifndef by xt00 on Monday March 15, 2021 @01:46PM (#26469074)
For the case of multiple else if’s using the below case would you need to start nesting them to get the same functionality as #elif?