Related articles |
---|
Symbols in library. atandin@free.fr (2003-07-31) |
Re: Symbols in library. v.Abazarov@attAbi.com (Victor Bazarov) (2003-08-04) |
Re: Symbols in library. artiegold@austin.rr.com (Artie Gold) (2003-08-04) |
Re: Symbols in library. alfps@start.no (2003-08-10) |
Re: Symbols in library. atandin@free.fr (2003-08-20) |
Re: Symbols in library. kamalp@acm.org (2003-08-23) |
Re: Symbols in library. vbdis@aol.com (2003-08-23) |
Re: Symbols in library. david.thompson1@worldnet.att.net (Dave Thompson) (2003-09-01) |
From: | alfps@start.no (Alf P. Steinbach) |
Newsgroups: | comp.compilers,comp.lang.c++ |
Date: | 10 Aug 2003 10:48:22 -0400 |
Organization: | Compilers Central |
References: | 03-07-214 |
Keywords: | C++, linker |
Posted-Date: | 10 Aug 2003 10:48:22 EDT |
On 31 Jul 2003 12:47:02 -0400, atandin@free.fr (Torbak) wrote:
>I got some question about symbols in libraries ...
>
>In libraries, there is public symbols and "not public" symbols
>(private, static)... In C when we use the "static" keyword on the
>declaration of a function, the function is not public in the library.
>
>1- When I use a class, all is symbols are put in the public section of
>the library. How can I change that.
If you can forget about "libraries" and "object files", which are not
specified by the C++ standard, the answer to what you probably intend
to ask is to use
* An anonymous namespace.
Example:
namespace // anon
{
class C
{
...
};
}
>The keyword "private" in a class is only for the langage or does it
>change (like "static") something in libs ? Even in object file ?
That, including the possible existence of libraries and object files,
depends on the compiler and linker (if a linker exists).
>2- Even symbols which are not "static" have there decorated name in
>the library. (I use bindump to check that). How can I avoid that for
>the private functions of my lib ?
A literal interpretation of that question is meaningless.
Perhaps you mean: "Even when a non-member function is declared as
'static' I get a name conflict with another compilation unit". In
that case your compiler is broken. However, the mere presence of
a name in some compiled form of the C++ source does not mean that
there will be a name conflict, e.g., it might be debug information.
But most probably what you meant is literally what you wrote, which
means some confusion about the effect of the word 'static'.
>What COFF is use for then ?
<ot>
COFF is an object file format. Use Google to find more info.
</ot>
>3- The keyword "static" is used to keep the use of something in the
>file scope.
Nope. 'static' has many different meanings depending on context.
If a non-member function or variable or constant is declared 'static'
then usage of that entity is restricted to the _compilation unit_,
which might comprise many files.
>If my lib is composed from many object file, how can I "hide" private
>functions ?
Interpretation: "How can avoid name clashes for functions that are
only used within one compilation unit?".
Most people just use 'static', at least, I _believe_ that's what most
people do. Some strictly standard-conforming people use anonymous
namespaces. That's because 'static' is deprecated for this usage, so
in some far-fetched theoretical sense it might stop working in version
3247.8 of some non-commercial experimental compiler, far in the future.
>Does somebody know how I can get a good documentation about library
>files ?
Start a new thread here, or search for old threads, about
documentation of the standard library, if that's what you mean.
You might also check the FAQ.
If you actually mean 'library files' as in '.lib files', that's
compiler- and system-specific, so check your compiler and system
documentation.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.