473,326 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

extern "C" and C++ files

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 ?

Jun 30 '07 #1
2 1364
Gray Alien wrote:
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
Jun 30 '07 #2
On Jun 30, 4:04 pm, Alan Woodland <a...@aber.ac.ukwrote:
Gray Alien wrote:
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?
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.)

--
James Kanze (Gabi Software) email: ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jul 1 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: cppaddict | last post by:
In JNI header files generated by javah, what is going on with the 'extern "C"' which is inserted around the native method when "cplusplus" is defined. I would think you would only need extern...
111
by: JKop | last post by:
Okay here we go, I feel it's about time people conversed about the bullshit aspects of C++ (including the bullshit stuff brought forward from C). I'll begin with a few of my own grievances: 1)...
2
by: flyaflya | last post by:
I want use a c lib in vc6. so I use extern "C" to c function, include three files "test.cpp", "b.h" and "b.c": //************************************************ // test.cpp #include...
8
by: Generic Usenet Account | last post by:
Our C++ program was linked with some legacy C functions. We had used the extern "C" declaration, and everything was working fine. Then someone thought that it would be better to have a consistent...
4
by: cpptutor2000 | last post by:
Could some C++ guru help me please? I am trying to build an application using gcc 3.2.3, that has a some classes using functions defined in some C files in the same directory. If inside the C++...
10
by: Mark A. Gibbs | last post by:
I have a question about mixing C and C++. In a C++ translation unit, I want to define a function with internal linkage and C calling convention. Here's a sample of what I want to do: //...
12
by: G Patel | last post by:
I've seen some code with extern modifiers in front of variables declared inside blocks. Are these purely definitions (no definition) or are they definitions with static duration but external...
19
by: ccwork | last post by:
Hi all, I am reading "C: A Reference Manual" 4th ed and I get lost for the "extern". It says that global object without specifying the storage-class specifier will have "extern" as the default...
5
by: jchludzinski | last post by:
I have 3 files (see below: a.h, w.c, ww.c). I would like to use a single x (declared somewhere) which would global to both compilation units: w.c & ww.c. No matter where I place the "extern"...
2
by: Bharath | last post by:
Hi All, I am a newbie to C++ and I'm trying to figure this out. Can you please help? We have 3rd party library that's written in c++. We don't have the source for it. ldd on that shared...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.