how to call a C++ function from a C file when provided with only compiled code

Discussion in 'C++' started by ankitjain.bvcoe@gmail.com, Sep 15, 2006.

  1. Guest

    I have an existing C++ library . Now i am another application using
    this C++ lib.
    The problem here is i want to call C++ fn. from C file .I cannot use
    extern "C"declaration for that fn. because it is compiled using a g++.

    tobeused.cc

    writtenincpp(int i ,char c)
    {
    }

    Since i have been provided with .o's and the header files ,i can change
    only function prototypes and not function declaration.

    What should i do ?

    regards,
    ankit
    , Sep 15, 2006
    #1
    1. Advertising

  2. David Harmon Guest

    On 14 Sep 2006 22:08:07 -0700 in comp.lang.c++,
    "" <> wrote,
    >The problem here is i want to call C++ fn. from C file .I cannot use
    >extern "C"declaration for that fn. because it is compiled using a g++.


    You need to write a "glue" function to go between. It should be
    compiled as C++, with an extern "C" attribute so that it can be
    called from your C code.
    David Harmon, Sep 15, 2006
    #2
    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. Rachel Forder
    Replies:
    2
    Views:
    362
    Rachel Forder
    Oct 12, 2003
  2. Klaus Schneider
    Replies:
    1
    Views:
    518
    Rolf Magnus
    Dec 2, 2004
  3. Ham
    Replies:
    5
    Views:
    642
    Jack Klein
    Sep 26, 2006
  4. lander
    Replies:
    5
    Views:
    567
    bruce barker
    Mar 5, 2008
  5. Dhananjay
    Replies:
    0
    Views:
    726
    Dhananjay
    Mar 26, 2009
Loading...

Share This Page