开发者

Compiling C to use the CLR [duplicate]

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜