Path: utzoo!attcan!uunet!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!haven!decuac!mountn.dec.com!labc!wallis From: wallis@labc.dec.com (Barry L. Wallis) Newsgroups: comp.lang.c Subject: Re: COMMONS in C Summary: Order of variables in VAX C Keywords: C, ANSI C, VAX C Message-ID: <1477@mountn.dec.com> Date: 21 Mar 90 23:56:14 GMT Sender: news@mountn.dec.com Organization: Digital Equipment Corporation Lines: 32 In article <1990Mar21.031726.18192@bpdsun1.uucp>, dwg@bpdsun1.uucp (David W. Glessner) writes... >In article <1990Mar19.213645.1962@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: > in structures >>Both K&R1 and ANSI C say the order ^ must be preserved. > >Are any guarantees made about the order (i.e. addresses) of external >variables? The order of variables in a structure statement *must* be preserved (UNION wouldn't be much use otherwise). However variables which are independent from each other have no such guarantee. The following is from the _VAX C Run-Time Library Reference Manual (V3.1)_: "The C language does not gurantee any memory order for the variables in a declaration. For example, int a, b, c; "The VMS Linker (linker) usually places VAX C extern variables in program sections (psects) of the same name as the variable. The linker then alphabetically links the psects by name. If you are porting a C program from another operating system to a VMS system, you may find that the order of items in the program has been allocated differently in virtual memory. This causes existing programs with hidden bugs to fail" --- Barry L. Wallis USENET: wallis@labc.dec.com Database Consultant Prodigy (don't laugh): DNMX41A U.S. DECtp Resource Center DECUServe: EISNER::WALLIS (not on the net yet) Los Angeles, CA "No one voted for me, I represent myself" ---