COMMONS in C

Barry L. Wallis wallis at labc.dec.com
Thu Mar 22 09:56:14 AEST 1990


In article <1990Mar21.031726.18192 at bpdsun1.uucp>, dwg at bpdsun1.uucp (David W. Glessner) writes...
>In article <1990Mar19.213645.1962 at utzoo.uucp> henry at 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 at 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"
---



More information about the Comp.lang.c mailing list