Global Variables

Issue: global shadowing without error

Two global structures were defined under the same name in different components. No error was raised by linker.

Checking default options:

gcc -Q --help=common

shows that -fcommon is enabled.

From gcc-arm-none-eabi-9-2020-q2-update/share/doc/gcc-arm-none-eabi/info/gcc.info:

-fno-common

   '-fno-common'
   In C code, this option controls the placement of global variables
   defined without an initializer, known as "tentative definitions" in
   the C standard.  Tentative definitions are distinct from
   declarations of a variable with the 'extern' keyword, which do not
   allocate storage.
   Unix C compilers have traditionally allocated storage for
   uninitialized global variables in a common block.  This allows the
   linker to resolve all tentative definitions of the same variable in
   different compilation units to the same object, or to a
   non-tentative definition.  This is the behavior specified by
   '-fcommon', and is the default for GCC on most targets.  On the
   other hand, this behavior is not required by ISO C, and on some
   targets may carry a speed or code size penalty on variable
   references.
   
   The '-fno-common' option specifies that the compiler should instead
   place uninitialized global variables in the BSS section of the
   object file.  This inhibits the merging of tentative definitions by
   the linker so you get a multiple-definition error if the same
   variable is defined in more than one compilation unit.  Compiling
   with '-fno-common' is useful on targets for which it provides
   better performance, or if you wish to verify that the program will
   work on other systems that always treat uninitialized variable
   definitions this way.
   

https://developer.arm.com/documentation/101754/0623/armclang-Reference/armclang-Command-line-Options/-fcommon---fno-common