c calling c++ functions

T

teju

hi,

i have a code written in c now merged with c++ code i mean i am
calling c functions in c++ using extern "C" but now i want to use some
objects declared and defined in c++ to be available in c code.

how can i do this?

please reply,
thanx
 
P

Peter Nilsson

teju said:
hi,

i have a code written in c now merged with c++ code i mean
i am calling c functions in c++ using extern "C" but now i
want to use some objects declared and defined in c++ to be
available in c code.

how can i do this?

C++ grants a licence to merge C with C++. C does not. In other
words, C++ knows about C, but C does not know about C++.

You should ask your question in a C++ forum.
 
I

Ian Collins

Peter said:
C++ grants a licence to merge C with C++. C does not. In other
words, C++ knows about C, but C does not know about C++.

You should ask your question in a C++ forum.
After you check the archives of both groups, this question has been
asked more times than I care to remember.
 
L

lovecreatesbea...

C++ grants a licence to merge C with C++. C does not. In other
words, C++ knows about C, but C does not know about C++.

There is a faq on the C++ inventor's homepage talking about C and C++
call each other. Is the C mentioned on that webpage K&R C and/or ANSI
C, or is it just another kind of C in C++?

http://www.research.att.com/~bs/bs_faq2.html

How do I call a C function from C++?
How do I call a C++ function from C?
 
P

Pierre Asselin

teju said:
i have a code written in c now merged with c++ code i mean i am
calling c functions in c++ using extern "C" but now i want to use some
objects declared and defined in c++ to be available in c code.
how can i do this?

By passing pointers and treating these pointers as opaque on the
C side. To do anything, you will have to write more extern "C"
helper functions in C++.

In general you can't manipulate C++ objects directly from C.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,303
Messages
2,571,559
Members
48,361
Latest member
arunkumar00
Top