3 ms·
> Except that text inside #if 0 still has to lex correctly. Are you sure? I just tried on godbolt and that’s not true with gcc 14.2. I’ve definitely put syntax
by dahart 2y ago
> Except that text inside #if 0 still has to lex correctly.
Are you sure? I just tried on godbolt and that’s not true with gcc 14.2. I’ve definitely put syntax errors intentionally into #if 0 blocks and had it compile. Are you thinking of some older version or something? I thought the pre-processor ran before the lexer since always…
- fanf2 2y agoThere are three (relevant) phases (see “translation phases” in section 5 of the standard): • program is lexed into preprocessing tokens; comments turn into whitespace • preprocessor does its thing • preprocessor tokens are turned into proper tokens; different kinds of number are disambiguated; keywords and identifiers are disambiguated If you put an unclosed comment inside #if 0 then it won’t work as you might expect.
- dahart 2y agoAh, I see. You’re right!