Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Abstract Syntax Tree for C programs Date: Tue, 04 Jun 2019 22:11:00 -0700 Organization: None to speak of Lines: 47 Message-ID: References: <5dd4672f-a571-40bc-bb1a-c14f6c631eb7@googlegroups.com> <8d90e6a8-097d-4573-a88a-1f5f56dda26d@googlegroups.com> <8736kp2yss.fsf@bsb.me.uk> <86y32hfi2i.fsf@mailhub.linuxsc.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="2e5690e26a3a02612d58fbc15f6a6031"; logging-data="3410"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199gRIowxU5tCxLTC392Lyj" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:rHBAbhOgy82JEsxZUkHekZv4CuA= sha1:xnDcESbyinoMGOc6X3WCtqnFOuM= Xref: csiph.com comp.lang.c:144459 David Brown writes: [...] > Is there code that is valid in C90 and C99, but has a different meaning? > I can't think of any off-hand, but I would not rule it out. #include int main(void) { int is_c90 = -1 //* /**/ +1; printf("This %s C90\n", is_c90 ? "is" : "is not"); return 0; } In C90, the first "/" is a division operator, which is immediately followed by a comment that ends just before the "+1", so the initializer is `-1 / +1`. In C99 or later, the "//" introduces an end-of-line comment, and the next line consists of a comment followed by the second half of the initializer, so the initializer is `-1 + 1`. (The "+", which is a unary operator in the C90 version, becomes a binary operator in the C99/C11 version.) Or there's the brute force approach: #include int main(void) { #if defined __STDC__ #if !defined __STDC_VERSION__ puts("This is C90"); #elif __STDC_VERSION__ == 199901L puts("This is C99"); #elif __STDC_VERSION__ == 201112L puts("This is C11"); #else puts("__STDC_VERSION__ is not recognized"); #endif #else puts("__STDC__ is not defined"); #endif return 0; } -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */