简体   繁体   中英

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

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM