IT lexicon › Programming › Common symbol

Common symbol

Programming På svenska → Updated: 2026-11-07

An uninitialised global that the linker is allowed to merge with same-named copies from other object files instead of complaining about duplicate definitions.

Write int count; in a header included by ten C files and you get ten definitions. Unix compilers long papered over this by marking such tentative definitions as COMMON symbols. The linker keeps one, picking the largest size if they disagree. The pattern descends from Fortran's COMMON blocks. The C standard doesn't allow it, but lists it as a common extension.

In 2020 GCC 10 switched the default to -fno-common, and Clang 11 followed the same year. Overnight a pile of old projects stopped linking with multiple definition errors. The bug had been there for thirty years; it was just the first time anyone mentioned it. The proper fix is extern in the header and exactly one definition in a source file.

← Back to the lexicon