Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual C++
Reference
C/C++ Languages
Pragma Directives
 make_public
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
C/C++ Preprocessor Reference
make_public

Indicates that a native type should have public assembly accessibility.

#pragma make_public(type)

Parameters

type is the name of the type you want to have public assembly accessibility.

make_public is useful for when the native type you want to reference is from a .h file that you cannot change. If you want to use the native type in the signature of a public function in a type with public assembly visibility, the native type must also have public assembly accessibility or the compiler will issue a warning.

make_public must be specified at global scope and is only in effect from the point at which it is declared through to the end of the source code file.

The native type may be implicitly or explicitly private; see Type Visibility for more information.

The following sample is the contents of a .h file that contains the definitions for two native structs.

// make_public_pragma.h
struct Native_Struct_1 { int i; };
struct Native_Struct_2 { int i; };

The following code sample consumes the header file and shows that unless you explicitly mark the native structs as public, using make_public, the compiler will generate a warning when you attempt to use the native structs in the signature of public function in a public managed type.

// make_public_pragma.cpp
// compile with: /c /clr /W1
#pragma warning (default : 4692)
#include "make_public_pragma.h"
#pragma make_public(Native_Struct_1)

public ref struct A {
   void Test(Native_Struct_1 u) {u.i = 0;}   // OK
   void Test(Native_Struct_2 u) {u.i = 0;}   // C4692
};
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Nice      mMasum   |   Edit   |   Show History
This is a helpful feature for c++/CLI programmers, Specially who is working with native c++ code in mixed mode.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker