In a complex solution I have a mix of native C++ library, C++/CLI wrappers and C# assemblies. In the wrappers I often have to use native types so I have to make them public using #pragma make_public
. The problem with those pragmas however is that you often get linker error LNK2022 as discussed here and here (and many other places).
The usual solution is to collect all pragmas in one place to avoid the duplicate type error. So far the only reliable place I found was to put the list in my stdafx.h
header file. This is however annoying as it causes my entire project to recompile as soon as I have to add a new native type there (it's my precompiled header).
I'd like to extract that list to a separate header or, even better, cpp file. But my attempts so far have not worked. The types where not made public. It also seems I have to put the #pragma make_public
calls in a header file. I'd prefer a cpp however.
So, what other possibilties exist? Where do others place their #pragma make_public
calls?