Is -fcommon reliable?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Consider the the following code:

  // Header foo.h:
  const double FooLength;
  const double FooMass;

  // Source file foo.c:
  #include "foo.h"
  const double FooLength = 4.2;
  const double FooMass = 10.5;

  // Source file bar.c:
  #include foo.h
  ...

This is non-standard C, but it is correct if you rely on the '-fcommon'
feature of GCC which merges tentative definitions across translation
units. I find '-fcommon' to be a convenient and useful feature because
it allows you to omit 'extern' specifiers on declarations of global
constants.

My question is: if I rely on '-fcommon' in this way in my own software,
is it likely to cause any problems for me down the line? For example,
are there any plans to deprecate '-fcommon' in GCC in the future?

Regards,

Rob Henderson

Additional notes:
 () The '-fcommon' functionality is described in K&R in a footnote (2nd
edition, Sect. A10.2, pg. 227) as an "alternate formulation, ... usual
in UNIX systems and recognised as a common extension by the Standard".
 () The GNU LD manual, Sect. 2.1, describes reliance on '-fcommon' as a
"somewhat sloppy practice".



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux