Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!munnari.oz.au!yoyo.aarnet.edu.au!sirius.ucs.adelaide.edu.au!spam!ross From: ross@spam.ua.oz.au (Ross Williams) Newsgroups: comp.lang.c Subject: Are definitions evaluated in order? Summary: Are definitions evaluated in order? Keywords: c programming language definitions evaluation order Message-ID: <895@spam.ua.oz> Date: 27 Jun 91 07:03:31 GMT Sender: ross@spam.ua.oz Followup-To: comp.lang.c Organization: Statistics, Pure & Applied Mathematics, University of Adelaide Lines: 38 Does C guarantee that it will evaluate declarations in order? For example, is the following program guaranteed to output "3"? main() { int a=3; int b=a; printf("%d\n",b); } And how about: main() { int a=3,b=a; printf("%d\n",b); } Even if it is standard, does anyone know if it is practically portable (i.e. do compilers as a rule evaluate in order). I am asking because it would neaten up a lot of the code I am writing. Without the order assumption, variables that are dependent on other variables initialized in the same block have to be initialized using assignments instead of at their declaration. I don't just need a yes or a no, I need a specific reference to [K&R] or the ANSI standard ([K&R] preferred as I don't have a copy of the standard). Without a formal language spec reference, I won't have a warm fuzzy feeling about it. Thanks, Ross Williams ross@spam.ua.oz.au