Becky Green
Becky Green

Reputation: 645

Compile C code into Visual C++ dll?

Is it possible to compile C code into a Visual C++ dll? I'm looking at using some C code with a .Net project and trying to determine whether this is even an option.

Thanks, Becky

Upvotes: 1

Views: 351

Answers (2)

Timo Geusch
Timo Geusch

Reputation: 24351

Given that C++ is largely backward compatible with C, you should be able to recompile the code using the C++ compiler unless the code uses some C99 features. However, keep in mind that C++/CLI is not standard C++ so there might be additional issues.

As aJ said, if you want to avoid the name mangling, you'll have to 'extern C' the symbols.

Another way to accomplish this would be to leave the C library as standard native code and write a thin C++/CLI layer for it. Then expose the C++/CLI layer to your .NET application.

Upvotes: 1

aJ.
aJ.

Reputation: 35470

yes. If you want to get rid of name mangling use "extern "C" { /*...*/ } construct.

Also, refer FAQ : How to mix C and C++

Upvotes: 2

Related Questions