extern "C" in C++/CLI?
-
Short questions: Can I include old C code? So far I was used to have an extern "C" block around the corresponding include-instructions. Is this still possible in C++/CLI, or does "managed C++" not allow any C code at all? At least the compiler tells me that the file I wanted to include cannot be compiled with /clr option. ;-)
-
Short questions: Can I include old C code? So far I was used to have an extern "C" block around the corresponding include-instructions. Is this still possible in C++/CLI, or does "managed C++" not allow any C code at all? At least the compiler tells me that the file I wanted to include cannot be compiled with /clr option. ;-)
Don Rolando wrote:
Short questions: Can I include old C code?
Yes
Don Rolando wrote:
So far I was used to have an extern "C" block around the corresponding include-instructions.
I don't know what you mean but I just added these, compiled and executed my project without error.
extern "C" int getfoo(){ return 12; }
extern "C" int getbar(){ return 14; }int _tmain(int argc, _TCHAR* argv[])
{System::Console::WriteLine("Mixed Mode Console (v 1.0)");
System::Console::WriteLine(System::String::Format("foo: {0}", getfoo()));
System::ConsoleKeyInfo ki = System::Console::ReadKey();
return 0;
}led mike