Re: c++ calling c functions
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Fri, 07 Dec 2007 11:50:12 -0800
CBFalconer <cbfalconer@xxxxxxxxx> writes:
Keith Thompson wrote:
CBFalconer <cbfalconer@xxxxxxxxx> writes:... snip ...
Note that this does NOT affect the object code in any way, only
the headers. You can't invert this and generate normal C++
modules that can be linked into a C program. Note the "normal".
What exactly do you mean by "normal"? Does the use of extern "C",
a feature defined by the C++ standard, render code abnormal?
I think we are getting at the heart of the disagreement. To me, a
normal C++ 'module' contains such things as functions with modified
names, reflecting the parameters, and used to separate the various
forms. The code has not been modified by an "extern C" clause. It
is usable without special care in any C++ program. (There is some
speculation here, because I don't really use C++).
I think the problem is that you're associating "C++" with an object
code module. C++ is a source code language. The contents of an
object module generated by a C++ compiler from a C++ source file are
entirely implementation-specific. The mangled names are not part of
C++; they're something used by the implementation, largely invisible
to portable C++ code.
And once again, extern "C" is a C++ feature. It's specified by the
C++ standard, and there is absolutely nothing "abnormal" or non-C++
about it.
A C++ source file containing an extern "C" directive is 100% pure C++.
To call that system from a C module, something has to supply the
modified function name. There is no such provision in C. It is
hard to add controlled gubris to a function name. Therefore you
can't call the C++ code from C.
Then please explain how I'm able to do exactly that. You can do so
only by assigning nonsensical meanings to the phrases "C code" and
"C++ code".
[...]
--
Keith Thompson (The_Other_Keith) <kst-u@xxxxxxx>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- Follow-Ups:
- Re: c++ calling c functions
- From: CBFalconer
- Re: c++ calling c functions
- References:
- c++ calling c functions
- From: teju
- Re: c++ calling c functions
- From: CBFalconer
- Re: c++ calling c functions
- From: Bill Reid
- Re: c++ calling c functions
- From: CBFalconer
- Re: c++ calling c functions
- From: Keith Thompson
- Re: c++ calling c functions
- From: CBFalconer
- Re: c++ calling c functions
- From: Keith Thompson
- Re: c++ calling c functions
- From: CBFalconer
- Re: c++ calling c functions
- From: Keith Thompson
- Re: c++ calling c functions
- From: CBFalconer
- c++ calling c functions
- Prev by Date: Re: How to disassemble with objdump and recompile the program ?
- Next by Date: Re: String Concatenation Using Pointers No strcat()
- Previous by thread: Re: c++ calling c functions
- Next by thread: Re: c++ calling c functions
- Index(es):
Relevant Pages
|