PRB: "UNRECOVERABLE APPLICATION ERROR: No Main Procedure"

Last reviewed: July 17, 1997
Article ID: Q78202
7.00 | 1.00 1.50 MS-DOS | WINDOWS kbprg kbprb

The information in this article applies to:

  • The C Run-time (CRT), included with:

        - Microsoft C/C++ for MS-DOS, version 7.0
        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

SYMPTOMS

When starting a Windows or QuickWin application built with QuickC for Windows (QC/Win) version 1.0, C/C++ version 7.0, or Visual C++, the following message may appear:

   UNRECOVERABLE APPLICATION ERROR

        no main procedure

CAUSE

This message is generated if the application in question does not define a main() or WinMain() function. Because the C startup code uses weak externals to allow WinMain() to fix up main(), it is impossible to issue the message at compile time, as is done for an executable file designed for the MS-DOS operating system. A stub delivers the error message at run time.

RESOLUTION

To avoid this error, make sure that you define the proper entry point, as follows:

    WinMain()             for a Windows .EXE
    main() or WinMain()   for a QuickWin .EXE

MORE INFORMATION

The C startup code makes a weak external call to the main() function. If main() cannot be found, then a stub version of main() [the stub that gets control if there is no main() function in the program] makes a weak external call to WinMain(). If WinMain() cannot be found, a stub version of WinMain() issues the UAE.

Note that if a Windows .EXE has main() declared with the C calling convention or _main() declared with the Pascal calling convention, the program will compile successfully and the UAE will not occur. However, the program will terminate normally during execution of the startup code, without entering the application code.


Additional reference words: 7.00 1.00 1.50
KBCategory: kbprg kbprb
KBSubcategory: CRTIss
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.