DOCERR: Function Returning Zero When Redefining _nullcheck()

Last reviewed: July 17, 1997
Article ID: Q67084
6.00 6.00a 6.00ax 7.00 | 6.00 6.00a | 1.00 1.50 1.51 1.52
MS-DOS                 | OS/2       | WINDOWS
kbprg kbdocerr

The information in this article applies to:

  • Microsoft C for MS-DOS, versions 6.0, 6.0a, and 6.0ax
  • Microsoft C for OS/2, versions 6.0 and 6.0a
  • Microsoft C/C++ for MS-DOS, version 7.0
  • Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, and 1.52

By default, Microsoft C checks the NULL segment before the final termination of a program in order to determine if a null pointer assignment has occurred. This check can be suppressed by defining your own function called _nullcheck(), which is the name of the library routine that is normally linked in to do the checking.

The online Help for C versions 6.0, 6.0a, 6.0ax, C/C++ versions 7.0, and 8.0 describes how to replace this function, but there is an error in those Help files. The online Help states that you just need to declare your own routine "named _nullcheck that does nothing". This is not completely true. You actually need to make your function return a value of zero; otherwise, the program exit code will be set to 255.

The following is a valid way to define the _nullcheck() function in your program:

    int _cdecl _nullcheck( void)
    {
        return (0);
    }

NOTE: This information does not apply to Visual C++ 32-bit Edition, because of memory addressing differences. Exception handling should be used instead.


Additional reference words: 6.00 6.00a 6.00ax 7.00 1.00 1.50
KBCategory: kbprg kbdocerr
KBSubCategory: CLngIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.