Exporting Symbols From C++ Object File

Discussion in 'C++' started by chetan, Sep 23, 2004.

  1. chetan

    chetan Guest

    Hi ,
    myself Chetan

    Is There anybody could help me ?

    I am working on the project in c++ ,, I am in great confusion that
    should I export c++ member functions OR methods to create objects of
    that class OR
    previously cretaed objects .. So those can be used by users by using
    the header file ... of my " class "

    But by exporting member functions of C++ class user would not
    understand
    which are the private // public functions and would get compilation
    error ..!!!
    OR may simply change the header file from private to public and would
    use
    private functions ....!!!

    So I need information that how compiler checks that a perticular
    symbol is private and won't allow us to call it by object from
    anywhere ...

    Because simply looking at the symbol table from ELF file it's not
    getting clear diffrence between the public and private
    functionss...!!!


    So help ..!!!
     
    chetan, Sep 23, 2004
    #1
    1. Advertising

  2. chetan

    Sharad Kala Guest

    "chetan" <> wrote in message

    > Hi ,
    > myself Chetan


    I could guess from the header of your posting :)

    > Is There anybody could help me ?


    Sure, dozens out here.

    > I am working on the project in c++ ,, I am in great confusion that
    > should I export c++ member functions OR methods to create objects of
    > that class OR
    > previously cretaed objects .. So those can be used by users by using
    > the header file ... of my " class "


    I am also in great confusion as to what exactly you meant in the above
    lines. Care to give an example ?

    > But by exporting member functions of C++ class user would not
    > understand
    > which are the private // public functions and would get compilation
    > error ..!!!
    > OR may simply change the header file from private to public and would
    > use
    > private functions ....!!!
    >
    > So I need information that how compiler checks that a perticular
    > symbol is private and won't allow us to call it by object from
    > anywhere ...
    >
    > Because simply looking at the symbol table from ELF file it's not


    What is an ELF file ?

    > getting clear diffrence between the public and private
    > functionss...!!!


    Honestly I don't understand your question quite well (may be others might
    feel the same). In that case it would be better that you present your
    problem clearly with an example.

    Sharad
     
    Sharad Kala, Sep 23, 2004
    #2
    1. Advertising

  3. chetan

    Gregg Guest

    (chetan) wrote in news:4cb1a40c.0409222045.9e8b674
    @posting.google.com:

    > I am working on the project in c++ ,, I am in great confusion that
    > should I export c++ member functions OR methods to create objects of
    > that class OR
    > previously cretaed objects .. So those can be used by users by using
    > the header file ... of my " class "


    It sounds like you want to put a class in a library that users can link
    with. Is that correct?

    Unlike C, there is no industry standard for storing C++ symbol
    information in an object file (like "ELF") that is compatible with all
    compilers. You will probably therefore have to use the same compiler for
    both the library and the client code if you want to link symbolically.

    The alternative that is commonly done is to export an extern "C" function
    that is responsible for creating the object, which must have all virtual
    functions. The client then invokes functions through an abstract
    interface so it does not need to link symbolically. This is basically
    what COM does in Windows.

    > But by exporting member functions of C++ class user would not
    > understand
    > which are the private // public functions and would get compilation
    > error ..!!!
    > OR may simply change the header file from private to public and would
    > use
    > private functions ....!!!


    The public/private stuff is not represented in the binary file because it
    is only used at compile time, not run time. The client compiler will know
    which is private and which is public from the header file. You are right
    that the user could edit the header file, the access modes could be
    chcanged. That is the case even without libraries. It is only a compile-
    time mechanism.

    Gregg
     
    Gregg, Sep 23, 2004
    #3
  4. "chetan" <> wrote in message
    news:...
    > Hi ,
    > myself Chetan
    >
    > Is There anybody could help me ?
    >
    > I am working on the project in c++ ,, I am in great confusion that
    > should I export c++ member functions OR methods to create objects of
    > that class OR
    > previously cretaed objects .. So those can be used by users by using
    > the header file ... of my " class "
    >
    > But by exporting member functions of C++ class user would not
    > understand
    > which are the private // public functions and would get compilation
    > error ..!!!
    > OR may simply change the header file from private to public and would
    > use
    > private functions ....!!!


    Is that a problem? Why do you care? Are you being paranoid?

    >
    > So I need information that how compiler checks that a perticular
    > symbol is private and won't allow us to call it by object from
    > anywhere ...


    It looks in the header file. If the header file has been changed by the user
    there is not a lot you can do.

    >
    > Because simply looking at the symbol table from ELF file it's not
    > getting clear diffrence between the public and private
    > functionss...!!!
    >


    There is no answer to your problem. Public and private are meant to help the
    programmer, there are not a security system to stop the unauthorized
    execution of code. If that is what you are trying to do then you are going
    to have to look elsewhere.

    john
     
    John Harrison, Sep 23, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dennis Redfield
    Replies:
    1
    Views:
    439
    Ozzy Knox
    Aug 4, 2003
  2. Luis Esteban Valencia
    Replies:
    1
    Views:
    1,405
    Carl Prothman [MVP]
    Jan 12, 2005
  3. Nicolas Pourcelot

    exporting from Tkinter Canvas object in PNG

    Nicolas Pourcelot, Jan 11, 2005, in forum: Python
    Replies:
    0
    Views:
    299
    Nicolas Pourcelot
    Jan 11, 2005
  4. harold fellermann

    Re: exporting from Tkinter Canvas object in PNG

    harold fellermann, Jan 11, 2005, in forum: Python
    Replies:
    1
    Views:
    1,027
    Cameron Laird
    Jan 16, 2005
  5. Brian

    exporting symbols with ctypes?

    Brian, Apr 6, 2009, in forum: Python
    Replies:
    1
    Views:
    240
    Diez B. Roggisch
    Apr 6, 2009
Loading...

Share This Page