This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Why doesn't -fno-common really work???


Jack Howarth wrote:
Is this the presence of the common symbols in object code
compiled in g77 with -fno-common really non-broken behavior?

-fcommon/-fno-common are C front end options. They are not used by the C++ or Fortran front ends, and probably not by other front ends either.


-fno-common changes the behavior of C programs if you have the same uninitialized global variable defined in multiple files. So if you have
tmp.c:
int i;
tmp2.c:
int i;
then the default (-fcommon) is to accept this without complaint, but if you use -fno-common, you get a linker error for a multiply defined variable i. Some C compilers give -fno-common behavior by default.


These options are not appropriate for C++. I forget the details, but it violates the C++ language standard. Hence the C++ front end has its own option -fconserve-space which does something similar to -fcommon, but is not guaranteed to work. The default for C++ is effectively -fno-common.

I don't know enough about Fortran standards to say whether these options are appropriate. However, it seems to me that if you specified something is in a common block, then surely you meant for it to be common. How else you would implement common blocks otherwise? If common doesn't work with the Apple Mach-O linker, then that seems like an Apple problem. But since Apple doesn't support fortran, and binutils doesn't support Mach-O, you might be out of luck, and may have to find a work around.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]