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

Last reviewed: July 22, 1997
Article ID: Q113115
7.00 | 1.00 1.50 MS-DOS | WINDOWS kbtool kbbuglist

The information in this article applies to:

  • The Microsoft C/C++ Compiler (CL.EXE), included with:

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

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


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 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.