Discussion: Globals and Exports
Afficher un message
Vieux 05/05/2008, 12h12   #2
Antoninus Twink
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Globals and Exports

On 5 May 2008 at 9:53, Bartc wrote:
> I noticed that in C, functions in any module are automatically exported. So
> that it's not possible to use the same function name in two modules (ie.
> source files).
>
> Now that I know that, I get work around it; but is there a way to avoid the
> problem (short of lots of renaming)?


Check out your compiler's options. For example, gcc has quite a
sophisticated visibility model: in the simplest case, you can use
__attribute ((visibility("hidden"))) as a qualifier, or compile with
-fvisibility=hidden.

> More seriously, variables declared at file scope also seem to be
> automatically exported. But in this case, the compiler/linker doesn't warn
> me that the same name is being used in two or more modules. (Is this what
> the fuss is about with 'global variables'?)
>
> Is there any way I can fix this? (Like some keyword that will render a
> variable local to a module.)


static.

  Réponse avec citation
 
Page generated in 0,05272 seconds with 9 queries