1. Convert C Code to C++
Although Visual Studio will compile C files, it is necessary to convert them to C++ for a /clr compilation. The actual filename doesn't have to be changed; you can use /Tp(see /Tc, /Tp, /TC, /TP (Specify Source File Type).) Note that although C++ source code files are required for /clr, it is not necessary to re-factor your code to use object-oriented paradigms.
C code is very likely to require changes when compiled as a C++ file. The C++ type-safety rules are strict, so type conversions must be made explicit with casts. For example, malloc returns a void pointer, but can be assigned to a pointer to any type in C with a cast:
int* a = malloc(sizeof(int)); // C code int* b = (int*)malloc(sizeof(int)); // C++ equivalent
Function pointers are also strictly type-safe in C++, so the following C code requires modification. In C++ it's best to create a typedef that defines the function pointer type, and then use that type to cast function pointers:
NewFunc1 = GetProcAddress( hLib, "Func1" ); // C code typedef int(*MYPROC)(int); // C++ equivalent NewFunc2 = (MYPROC)GetProcAddress( hLib, "Func2" );
C++ also requires that functions either be prototyped or fully defined before they can be referenced or invoked.
Identifiers used in C code that happen to be keywords in C++ (such as virtual, new, delete, bool, true, false, etc.) must be renamed. This can generally be done with simple search-and-replace operations.
Finally, whereas C-style COM calls require explicit use of the v-table and this pointer, C++ does not:
COMObj1->lpVtbl->Method(COMObj, args); // C code COMObj2->Method(args); // C++ equivalent
2. References