Re: Symbols in library. (Kamal R. Prasad)
23 Aug 2003 23:13:18 -0400

          From comp.compilers

Related articles
Symbols in library. (2003-07-31)
Re: Symbols in library. (Victor Bazarov) (2003-08-04)
Re: Symbols in library. (Artie Gold) (2003-08-04)
Re: Symbols in library. (2003-08-10)
Re: Symbols in library. (2003-08-20)
Re: Symbols in library. (2003-08-23)
Re: Symbols in library. (2003-08-23)
Re: Symbols in library. (Dave Thompson) (2003-09-01)
| List of all articles for this month |

From: (Kamal R. Prasad)
Newsgroups: comp.compilers,comp.lang.c++
Date: 23 Aug 2003 23:13:18 -0400
References: 03-07-214
Keywords: C++, symbols
Posted-Date: 23 Aug 2003 23:13:18 EDT (Torbak) wrote in message news:03-07-214...
> I got some question about symbols in libraries ...
> 1- When I use a class, all is symbols are put in the public section of
> the library. How can I change that. The keyword "private" in a class
> is only for the langage or does it change (like "static") something in
> libs ? Even in object file ?

The private keyword refers to members (data or function) which can
only be accessed by members of that class- as per ANSI C++ standard.

> 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 ?
> What COFF is use for then ?

neither non-members within the library nor outside can access them
even if they see it , if they have been defined to be private. The
static keyword inside a class has a (slightly) different meaning. eg:-
class C {
int value;

unless you define an instance of class C, you will not be anle to set
the value.
with static, you can.
class C {
static int value;
class C::value = 1 is valid because there is no instance required.
Further, there is only one copy of the variable no matter how many
instances of the class C have been defined/malloc()'ed.

The ANSI C++ compiler makes no attempt to hide the field from
functions outside the scope of the C++ file where it is defined.

> 3- The keyword "static" is used to keep the use of something in the
> file scope.
Oustide the class/struct, if the static keyword is used, yes that is
what it is supposed to do.
> If my lib is composed from many object file, how can I
> "hide" private functions ?

Depends on whether you want to prevent access or hide info about
symbol names.
As another poster stated, you may want to use the external/internal
linkage stuff for the latter.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.