Amittai Aviram wrote: > The GCC manual explains the -fcommon and -fno-common flag with reference to traditional Unix practice: "In C code, controls the placement of uninitialized global variables. Unix C compilers have traditionally permitted multiple definitions of such variables in different compilation units by placing the variables in a common block." What exactly is a "common block" in this context? Where is it in the file and--assuming it's an ELF executable to be run on a Linux system--what segment (virtual address range) would the OS use for it, as opposed to the data section? Thanks! Variables in common blocks get folded into each other. So: ---file 1--- int i; ---file 2--- int i; ---end--- ...will refer to the *same* global variable. After linking they end up in the data segment just like any other global variable. They're not really recommended these days due to principle of least surprise; people are much better off using explicit declarations with extern instead. -- ┌─── dg@cowlark.com ───── http://www.cowlark.com ───── │ "Parents let children ride bicycles on the street. But parents do not │ allow children to hear vulgar words. Therefore we can deduce that │ cursing is more dangerous than being hit by a car." --- Scott Adams
Attachment:
signature.asc
Description: OpenPGP digital signature