Compiling C to use the CLR [duplicate]
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.
精彩评论