extern "C" From command line

Seyran Avanesyan seyran.avanesyan@tanner.com
Sat Aug 23 02:46:00 GMT 2008


> Then you need C linkage, which means you have no choice but to enclose
> the code in "extern C" (or compile it with a C compiler of course.)
If
> you really can't modify the source.cpp file then I still don't see why
> you can't do something like:
> 
> extern "C" {
> #include "source.cpp"
> }

Well, I can't do that because source.cpp allowed to contain #include-s.
(Of course I can parse source.cpp and create modified_source.cpp. Just
need to preprocess, then use yacc/lex or Spirit C-grammar parser...)

I can also write my own, simplified grammar parser for source.cpp (since
source.cpp is using C syntax).

But I just tried to compile with "-x c++" with extern "C" in souce.cpp
(experimentally added that manually), and when I tried to call it from
MSVC app I've got a crash.



More information about the Gcc-help mailing list