[cfe-dev] private extern, what is that?

Jean-Daniel Dupas devlists at shadowlab.org
Thu Nov 6 08:52:47 PST 2008


Le 6 nov. 08 à 16:41, Paolo Bolzoni a écrit :

> Function declarations and variable declarations can have private
> extern as storage class.
>
> I sought in the C and C++ standards for 'private extern' but I found  
> nothing.
> What does private extern mean?
> When the clang's AST can have private extern in one of its vertices?
>
> thanks
> pb

Declaring a symbol as private extern (using the __private_extern__  
keyword) is equivalent to declare it using  
__attribute__((visibility("hidden")))

http://developer.apple.com/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html

and

http://developer.apple.com/documentation/developertools/conceptual/MachOTopics/Articles/executing_files.html

A private external symbol is a defined external symbol that is visible  
only to other modules within the same object file as the module that  
contains it. The standard static linker changes private external  
symbols into private defined symbols unless you specify otherwise  
(using the -keep_private_externs flag).
You can mark a symbol as private external by using the  
__private_extern__ keyword (which works only in C) or the  
visibility("hidden")attribute (which works both in C and C++ with GCC  
4.0), as in this example:

__private_extern__ int x = 0;                       // C only
int y = 99 __attribute__((visibility("hidden")));   // C and C++, GCC  
4.0 only
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20081106/e0dd34d0/attachment.html>


More information about the cfe-dev mailing list