Managed / Unmamaged C++

  • Thread starter Thread starter Marcin Wieczorek
  • Start date Start date
M

Marcin Wieczorek

I'm trying to write a managed DLL that will wrap communications between
managed and unmanaged c++. All of the unmanaged code is lined to a static
lib. That lib contains tons of stuff like STL (which is my biggest
concern ) and other standard C lib stuff. I want to link that static lib
into the managed DLL. Is that possible?

So far I've been in linker hell and I can't think straight anymore...

Thanks,
Marcin
 
In general, yes.

Managed C++ comes with a technology called IJW that basically allows you to
call any code compiled in a static lib (or in a DLL with an import lib)
without any other thunking code. There are namespace issues between the
types in Win32 and .NET, but these can be solved by careful though of how
you use using namespace. There are also issues because managed C++ does not
allow you to declare empty types, for example:

struct _HIMAGELIST;
typedef _HIMAGELIST* HIMAGELIST;

this is take from commctrl.h and is fine as unmanged C++, but it will
generate an exception at runtime because _HIMAGELIST does not have a body.
(The solution is just to declare struct _HIMAGELIST{};).

There are other issues, but it is possible to solve them.

Richard
 
Back
Top