开发者

Compiling C to use the CLR [duplicate]

开发者 https://www.devze.com 2023-01-14 19:54 出处:网络
This question already has an answer here: 开发者_JAVA百科Closed 12 years ago. Possible Duplicate: Compiling C code for .NET
This question already has an answer here: 开发者_JAVA百科 Closed 12 years ago.

Possible Duplicate:

Compiling C code for .NET

I have a bunch of C source code and I want to compile it so it uses the .NET framework. I downloaded Microsoft Visual C++ and chose new CLR project. I then added all my C code, and I tried to compile the files. It said

cl : Command line error D8045: cannot compile C file '..\..\..\..\..\Downloads\lzma912\C\XzDec.c' with the /clr option

Why can't I compile this?


Sometimes, looking to MSDN can clarify the things. You need to force the compiler to treat C files as C++ files. See here.

To quote:

Only C++ source code files can be passed to a compilation that uses /clr. Use /TP to compile a .c file as a .cpp file; see /Tc, /Tp, /TC, /TP (Specify Source File Type) for more information.


Try to use the /Tp option so VC++ thinks your source file is C++ code instead of C. In that way you don't have to change your file extension.

0

精彩评论

暂无评论...
验证码 换一张
取 消