This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ld: common symbols not allowed with MH_DYLIB output
- From: "Sam Lauber" <sam124 at operamail dot com>
- To: "Mathieu Malaterre" <mmalater at nycap dot rr dot com>, gcc at gnu dot org
- Date: Tue, 07 Jun 2005 01:12:14 +0100
- Subject: Re: ld: common symbols not allowed with MH_DYLIB output
> int bar [ 4 * 256 ] = { 0,1,2, ... };
>
> I did not changed nor any compiler option, neither any
> declaration. I still cannot see the difference in between those
> two, since the declaration is exactly the same. The only difference
> being a default initialization.
There is a more subtle diffrence at work here. According to ANSI:
``An external declaration for an object is a definition if it has an initalizer.
*An external object declaration that does not have an initalizer, and does not
contain the extern specifier, is a tentaive definition.* If a definition for an
object appears in a translation unit, all its tentative definitions become a
single definition with initalizer 0.''
The highlighted sentence is very subtle, but it is the entire diffrence between
an executables `text' and `bss' sections. In Darwin, ``tentative definition''
is called ``common symbol''. _When you add the initalizer, you make the
definition non-tentative_. Got it? (If not, you should reread this paragraph.)
The moral of the story is, be sure to always read the fine print. (Translation:
keep track of subtleties when doing work.)
Samuel Lauber
--
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 8 at http://www.opera.com
Powered by Outblaze