BUG: C1001 in '@(#)p3io.c:1.29', Line 611

ID: Q113115

7.00 | 1.00 1.50 MS-DOS | WINDOWS kbtool kbbuglist

The information in this article applies to:

SYMPTOMS

If a function header and function prototype are mismatched such that one of them uses the "static" keyword and the other uses "__export", the following error is incorrectly generated by the optimizing compiler:

   fatal error C1001: internal compiler error
        (compiler file '@(#)p3io.c:1.29', line 611)

RESOLUTION

Static functions cannot be exported, and therefore the code is incorrect; however, the compiler issues the incorrect error message. If the function does not need to be static, then remove the static keyword and the code will compile cleanly. If the function does not need to be exported, then remove the __export keyword and the code will compile cleanly.

STATUS

Microsoft has confirmed this to be a problem in C/C++ versions 7.0, 8.0, and 8.0c. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Suppose a function named ExampleWindowProc is prototyped:

   (1) LRESULT CALLBACK __export ExampleWindowProc (WINDOWS_PARAMS)

If the function body includes the definition

   (2) static LRESULT CALLBACK ExampleWindowProc (WINDOWS_PARAMS)

the C1001 error will result. The error will also occur if the function is prototyped as in (2) but the function body has the definition shown in (1).

The compiler should generate a "C2201: cannot export static declarations" error message. You cannot export a static function because static functions have internal linkage. The code is also incorrect because the prototype does not match the function definition. The compiler does generate a C2201 error if the __export keyword is in the same prototype/function header as the static keyword.

NOTE: If the MakeProcInstance line is deleted in the code sample below, the compiler will not detect the error.

Sample Code

/*  Compiler options needed: /f- /c */ 

#include <windows.h>

FAR PASCAL MyProc( /*parameters*/ ); __export FAR PASCAL ConfDlg( /*parameters*/ );

static FAR PASCAL ConfDlg( /*parameters*/ ) {

    return (0);
}

FAR PASCAL MyProc(/*parameters*/) {

  DLGPROC lpProcDialog;
  HANDLE hInst;
  lpProcDialog = MakeProcInstance((DLGPROC) ConfDlg, hInst);
  return NULL;
}

Additional reference words: 1.00 1.50 7.00 8.00 8.00c L1101 import KBCategory: kbtool kbbuglist KBSubcategory: CLIss Keywords : kb16bitonly

Last Reviewed: July 23, 1997