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. Advertisements

  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. Advertisements

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. Replies:
    1
    Views:
    446
    =?Utf-8?B?RHVzdGluIHZhbiBkZSBTYW5kZQ==?=
    Apr 13, 2006
  2. Rachel Forder
    Replies:
    2
    Views:
    461
    Rachel Forder
    Oct 12, 2003
  3. Klaus Schneider
    Replies:
    1
    Views:
    775
    Rolf Magnus
    Dec 2, 2004
  4. Ham
    Replies:
    5
    Views:
    735
    Jack Klein
    Sep 26, 2006
  5. lander
    Replies:
    5
    Views:
    815
    bruce barker
    Mar 5, 2008
  6. Replies:
    33
    Views:
    4,406
    Ian Collins
    Apr 28, 2008
  7. bio
    Replies:
    6
    Views:
    501
    BartC
    Oct 2, 2010
  8. Dhananjay
    Replies:
    0
    Views:
    865
    Dhananjay
    Mar 26, 2009
Loading...