Re: Calling C++ from C



Hi,

I think you can mix and match C and C++ in the same project, the extern keyword is when you need to do external linkage and need a calling convention. Apparently, the IDE will invoke compilers slightly differently depending on whether you have an *.c or *.cpp file extension on the source file.

See the topic "Using extern to Specify Linkage" in the "Visual C++ Language Reference". This is a good place to start.

Andrew Chalk wrote:
To include C code in a C++ source module I can use

extern "C" ..

From C, can I include C++ code via some easy keyword? Or is this facility just not implemented.

I am using VC v8.0.

Many thanks.




--
Gerry Hickman (London UK)
.



Relevant Pages

  • Re: Pointer to extern char?
    ... How can there be a pointer to extern char? ... that the function has external linkage? ... static int a, *b, c; ... linkage when a declaration occurs at file scope, ...
    (comp.lang.c)
  • Re: extern
    ... The extern keyword usually gives you external ... % grep var a.c b.c ... Both have external linkage, but the "extern" in b.c inhibits ... "common block of size sizeof" will see the Fortran COMMON ...
    (comp.lang.c)
  • Re: (Why) Cant char* template parameters be const?
    ... >> Not sure why template parameters must have external linkage though. ... > Imagine you have two source files. ... When I made it extern, ...
    (comp.lang.cpp)
  • Re: how to use the keyword extern in c?
    ... > The extern keyword specifies that the identifier being declared has ... > external linkage. ... > includes) and referred to by name from code in other translation ... what's the difference when the keyword "extern" appears and when it doest appear? ...
    (comp.lang.c)
  • Re: extern
    ... >> 6.2.2p4 fully defines the meaning of the extern keyword, ... >> declaration with the extern keyword does not reverse the original ... Declared extern usually implies external linkage, ...
    (comp.lang.c)