Can I mix C++ and C in a single project in Visual Studio?

前端 未结 2 1687
南旧
南旧 2021-02-13 00:38

I have a a Win32 DLL project in VS2008, it is written in a handful of C modules.
Because I also want to be able to build outside VS2008, with no dependency on VS200

相关标签:
2条回答
  • 2021-02-13 00:59

    There's absolutely no problems mixing C and C++ in the same project. All you'll need to do it to design your interface between C and C++ modules in tems of C functions and C data structures, an then make sure that those interface functions are declared on C++ side with C-linkage specifier extern "C".

    0 讨论(0)
  • 2021-02-13 01:21

    First of all, you shouldn't even need /Tc if you're building it yourself - cl.exe uses file extension to determine the type, so .c files will be compiled as C by default, and .cpp and .cxx files as C++.

    For VS projects, it works in exact same way, except that you can't override this behavior (or at least I do not know how).

    0 讨论(0)
提交回复
热议问题