Microsoft KB Archive/310919

= PRB: Error Message When You Try to Locate a NULL Pointer in Managed Extensions for C++ =

Article ID: 310919

Article Last Modified on 5/21/2002

-

APPLIES TO


 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2002 Academic Edition

-



This article was previously published under Q310919



SYMPTOMS
In a Managed Extensions for C++ project, when you try to locate a null pointer by using the following code: System::Object* ptrObject; if(ptrObject != NULL) {  ... } you may receive the following error message:

&quot;error C2065: 'NULL' : undeclared identifier&quot;



CAUSE
The null value is a macro that is defined in the C/C++ header files. Those header files are not included in Managed Extensions for C++ projects.



RESOLUTION
Use zero (0), instead of null, as in standard C++. The code resembles the following sample code: System::Object* ptrObject; if(ptrObject != 0) {  ... }



STATUS
This behavior is by design.

Keywords: kbprb KB310919

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.