extern "C" and C++ files

G

Gray Alien

These are the "restrictions" I have come accross when "wrapping up" all
function declarations in a header with extern "C":

i). Inability to overload functions in exposed API
ii). Inability to include (template?) classes (e.g. string) in exposed API

Are there other ex/implicit restrictions I may have missed ?
 
A

Alan Woodland

Gray said:
These are the "restrictions" I have come accross when "wrapping up" all
function declarations in a header with extern "C":

i). Inability to overload functions in exposed API
ii). Inability to include (template?) classes (e.g. string) in exposed API

Are there other ex/implicit restrictions I may have missed ?
I'd guess bool wouldn't be portably usable too? and one would assume
references can't be exposed to a C compiler either?

Alan
 
J

James Kanze

I'd guess bool wouldn't be portably usable too? and one would assume
references can't be exposed to a C compiler either?

At the interface level, obviously, `extern "C"' doesn't make
much sense unless you stick to the common subset of C and C++.
(I would imagine that most, if not all, implementations, will
also make bool compatible with the C99 boolean type, and I can't
imagine an implementation where complex wasn't compatible with
it's C equivalents. But I don't think that the standards
guarantee this anywhere, and I'm not even sure how one would
formulate such guarantees.)
 

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,021
Latest member
AkilahJaim

Latest Threads

Top