Re: c++ calling c functions



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"
.



Relevant Pages

  • Re: Trouble with FILE
    ... CBFalconer writes: ... snip ... ... I'd settle for the first 62 lines ... and any headers. ...
    (comp.lang.c)
  • Re: Why segfault and no NULL match in for loop?
    ... CBFalconer writes: ... snip ... ... Saying a ".h file is NOT a place for headers" is like saying a ... headers and export them to a .h file. ...
    (comp.lang.c)
  • Re: c interview
    ... undefined behaviour because printf is a varidac function. ... stdio.h before using printf and other headers as appropriate before ... Would make it a point that the size of int is assumption to be .... ...
    (comp.lang.c)
  • Re: Float comparison
    ... snip ... ... trying to get an exact definition of them. ... speaking of the usual fp-system which normalizes everything in ... Chuck F (cbfalconer at maineline dot net) ...
    (comp.lang.c)
  • Re: How do I convert an int to binary form?
    ... pete wrote: ... snip ... ... The first time that our friend CBFalconer ... I can't recall any words from that thread to google on though. ...
    (comp.lang.c)