PRB: "UNRECOVERABLE APPLICATION ERROR: No Main Procedure"

ID: Q78202

7.00 | 1.00 1.50 MS-DOS | WINDOWS kbprg kbprb

The information in this article applies to:

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

Last Reviewed: July 18, 1997