newbie question regarding using c with c++

R

radiohead

hi,
can I call C from within C++ classes?
If so, where might i find resources on this?
Are there issues that i should be aware of?
thanks
chris
 
V

Victor Bazarov

radiohead said:
hi,
can I call C from within C++ classes?

Yes, you must be able to. That's basically how
the standard C library is used in C++.
If so, where might i find resources on this?

Any decent C++ book.
Are there issues that i should be aware of?

Not that I know of. Multithreading, perhaps,
but it's OT here. Try comp.programming.threads.

Victor
 
A

Artie Gold

radiohead said:
hi,
can I call C from within C++ classes?

Yes.
In order to do so, you need to have a prototype in scope with the
C function declared as `extern "C"' (so the compiler is aware that
no name-mangling is going on).
If so, where might i find resources on this?

Any decent C++ book.
Are there issues that i should be aware of?

There always are -- but I can't think of anything offhand.

HTH,
--ag
 
J

Jack Klein

Yes, you must be able to. That's basically how
the standard C library is used in C++.

I fail to see a requirement in the C++ standard that this is true.
There are functions that must be provided, and they must deliver the
results defined in the C90/95 ISO standard except as specifically
defined otherwise by the C++ standard. But not even C requires that
the C library be implemented in C.
Any decent C++ book.


Not that I know of. Multithreading, perhaps,
but it's OT here. Try comp.programming.threads.

Victor

Read the section on linkage. There is no requirement there at all
that any C++ implementation actually produce code that links with any
C implementation. There is an expression of intent, no testable
requirement at all.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
V

Victor Bazarov

Jack Klein said:
I fail to see a requirement in the C++ standard that this is true.

Did I say there was such a requirement? I guess, you failed to see
that what I wrote was merely a statement of fact that [on most known
implementations] C standard library is callable directly from C++
and the mechanism used is the same as needed to call a C function
from withing C++ classes.
 

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
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top