-fcommon (-qcommon)

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

Read syntax diagramSkip visual syntax diagram
>>- -f--+-common----+------------------------------------------><
        '-no-common-'   

Read syntax diagramSkip visual syntax diagram
>>- -q--+-common---+-------------------------------------------><
        '-nocommon-'   

Defaults

  • C only -fcommon (-qcommon) except when -shared (-qmkshrobj) is specified; -fno-common (-qnocommon) when -shared (-qmkshrobj) is specified.
  • C++ only -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


Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us