Compiler Error C2158
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C2158.
type' : #pragma make_public directive is currently supported for native non-template types only
The make_public pragma can only be applied to a native, non-template type.
The following sample generates C2158.
// C2158.cpp
// compile with: /clr /c
ref class A {};
#pragma make_public(A) // C2158
template< typename T >
class B {};
#pragma make_public(B) // C2158
#pragma make_public(B<int>) // C2158
void C () {}
#pragma make_public(C) // C2158
class D {};
#pragma make_public(D) // OK
Show: