Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!mcsun!ukc!inmos!wraxall!nigel From: nigel@wraxall.inmos.co.uk (Nigel Holder) Newsgroups: comp.std.c Subject: Weird identifier declaration Message-ID: <1898@brwa.inmos.co.uk> Date: 23 Aug 89 12:54:45 GMT Sender: news@inmos.co.uk Reply-To: nigel@inmos.co.uk () Organization: INMOS Limited, Bristol, UK. Lines: 39 Reading the ANSI spec closely I found the following weird case that enables the declaration of identifiers *after* assignment statements within the same block by using 'sizeof (type-name)'. The best way to illustrate this is with an example :- int main (void) { int a; a = 3; (void) sizeof (enum colour {red, green, blue}); printf ("red = %d, green = %d, blue = %d\n", red, green, blue); } The behaviour is similar to :- int main (void) { ... { enum colour {red, green, blue}; printf ( ... } } I guess the question is was this intentional ? (just for record you can also use the following instead of sizeof () : a = (enum colour {red, green, blue})3; as well !). Nigel Holder, INMOS Limited | mail[uk]: nigel@inmos.co.uk or ukc!inmos!nigel 1000 Aztec West, Bristol, UK | [us]: uunet!inmos-c!nigel Phone: +44 454 616616 x508 | Internet: @col.hp.com:nigel@inmos-c