> > I'd put this more simply...
> >
> > On Monday, June 6, 2005, at 02:06  PM, Mathieu Malaterre wrote:
> >>    I have a question about a valid C code. I am trying to 
> >> compile the following code in MacOSX (*). I don't understand 
> >> what the problem is?
> >
> > You must use -fno-common when you are building dynamic libraries on 
darwin.
> >
> >> Could someone please explain me what is going on?
> >
> > You didn't use -fno-common.
> >
> >
> >
> Can someone please tell me then which one of the three 
> possibilities is the right one:
> 
> #1. I need to tell the linker to use -single_module
> #2. Rewrite the code to make a fake initialization
> #3. I need to pass -fno-common to the compiler
>From a standpoint of just getting the thing deployed, any one of these three
is right.  

> I really don't understand why I need to do that, since this is 
> valid C code. Why the linker does not default to proper option, or 
> why the -fno-common option isn't used. At compile time gcc should 
> figure that out, right ?
The code parses, has the right nesting levels of blocks, arrays, parens, has
valid types, the statements are valid, ETC.  As far as the ANSI standard is
concerned, this code is valid, and it's the programmer's buisness to read
the documentation for the toolchain and understand that this kind of thing
might happen.  It is not GCC's buisness, it is not any ANSI compiler's
buisness, it is not any pre-ANSI compiler's buisness, it is not any compiler's
buisness.  GCC does not know and does not care that this might be invalid
input to the linker.  All that GCC cares about is that it is valid C code and 
the
assembler likes it's assembly output.  All other parts of the toolchain are not
anyone's buisness but the programmer.  The ANSI standard dosen't specify
anything about a linker; the only thing that makes GCC a compiler is the
assembly source it produces.  It isn't the compiler's buisness what goes in
the assembler's object file.  It isn't the compiler's buinsness what goes in the
final executable.  

> Now compared to the linker option, at least the compiler flag I can 
> specify it for the specific file I want, which is great. But then 
> again why is this up to the user to do it ? Is there a performance 
> reason ? Why isn't it the default ?
The compiler dosen't know that you might be making a dynamic library from
it's object file.  It dosen't know about the linker having that behavior.  
-fno-common is not default because it causes symbols to be moved out of
the BSS.  Moving symbols out of the BSS causes extra code to be generated.  
And most people agree that the BSS is the proper resting place for unitalized
symbols.  

> How do other people do when porting *nix lib to MacOSX ? Is this is 
> trial-and-error process to get the lib compiled ?
Perl does it by initalizing the values.  

Samuel Lauber

-- 
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 8 at http://www.opera.com

Powered by Outblaze

Reply via email to