Click to See Complete Forum and Search --> : [RESOLVED] /clr


TFobear
August 2nd, 2010, 08:43 AM
This may be obvious, but ill ask it anyways.

I have a native dll which I am converting to a managed one using the /CLR compiler switch in visual studio. It has a number of static (which I had previously converted from dynamic) libraries it draws from.

these libraries have some files being compiled as C code, rather than C++. Is it required to convert these libraries to /CLR and the C files to C++? I would assume if it was a clean native C++ transition it would be fine, I assume I dont really even need /CLR for the libraries. But I am new to interop.

Thank You.

TFobear
August 4th, 2010, 09:05 AM
found the answer to this question, which seems like it should have been obvious now. Anyways someone might wonder this in the future. If you have project with mixed native code and managed code, files with managed code should be compile with /clr individually while files with native without /clr. if you have managed code in a file but want some parts compiled as native, use


#pragma managed(push, off)
// Native Code
#pragma managed(pop)

//or

#pragma unmanaged
// Native Code
#pragma managed

// Not sure if there is a difference