-fcommon (-qcommon)
Category
Pragma equivalent
None.
Purpose
Controls where uninitialized global variables are allocated.
When -fcommon (-qcommon) is in effect, uninitialized global variables are allocated in the common section of the object file. When -fno-common (-qnocommon) is in effect, uninitialized global variables are initialized to zero and allocated in the data section of the object file.
Syntax
>>- -f--+-common----+------------------------------------------>< '-no-common-'
>>- -q--+-common---+------------------------------------------->< '-nocommon-'
Defaults
- -fcommon (-qcommon) except when -shared (-qmkshrobj) is specified; -fno-common (-qnocommon) when -shared (-qmkshrobj) is specified.
- -fno-common (-qnocommon)
Usage
This option does not affect static or automatic variables, or the declaration of structure or union members.
This option is overridden by the common|nocommon and section variable attributes. See The common and nocommon variable attribute and The section variable attribute .
Predefined macros
None.
Examples
In the following declaration,
where a and b are global variables:
int a, b;
Compiling
with -fcommon (-qcommon) produces the equivalent
of the following assembly code: .comm _a,4
.comm _b,4
Compiling with -fno-common (-qnocommon) produces
the equivalent of the following assembly code: .globl _a
.data
.zerofill __DATA, __common, _a, 4, 2
.globl _b
.data
.zerofill __DATA, __common, _b, 4, 2