On 2022-07-12 06:57:41 +0800, Ziyao wrote: > On Mon, Jul 11, 2022 at 05:47:31PM +0200, Domingo Alvarez Duarte wrote: > > Hello Ziyao ! > > > > Although gcc compiles a file containing your example with warnings, I'm not > > sure it's worth try to do the same in TiinyCC the preprocessor probably uses > > TOKENS from the lexer to decide to skip till the end of the initial "#if 0" > > and '"' is not a valid token the error probably come from the lexer that > > found a non terminated string. > > > For conditional inclusion,C99 document says: > Only the first group whose control condition evaluates to true > (nonzero) is processed. If none of the conditions evaluates to true, > and there is a #else directive, the group controlled by the #else is > processed; lacking a #else directive, all the groups until the > #endif are skipped.1 > In my understanding,the skipped part should NOT be processed.
To be able to skip it, the compiler needs to parse it as described in 6.10. So code like #if 0 #if 1 #else foo #endif #else OK #endif should give OK. And if anything violates the syntax during parsing, one should get a diagnostic. -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel