BUG: Class Export with Inline Constructor Causes L2022

Last reviewed: July 22, 1997
Article ID: Q114153
1.00 1.50 1.51 1.52 WINDWOS kbtool kbbuglist

The information in this article applies to:

  • The Microsoft C/C++ Compiler (CL.EXE), included with: Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, and 1.52

SYMPTOMS

If class _export syntax is used on a class with virtual functions and all constructors are inline then the virtual function table definition will not be placed in the OBJ file. If the below sample is compiled and linked it will generate the following error:

LINK : error L2022: ??_7CTest@@6B@ : export undefined

CAUSE

The error is caused because the symbol definition has not been placed in the .OBJ file, but an EXPDEF record has been generated which references it. Note that this problem will occur whether you use the _inline format for your constructors or you use the "implied _inline" C++ syntax of defining the constructor in your class declaration, for example:

class _export CTest {

  CTest() {};
};

The L2022 error will be caused any time an EXPDEF error is created and no definition exists. This will happen when you use "class _export <name>" with either the /GD or with /GA and /GEe.

RESOLUTION

Provide at least one constructor which is NOT inline.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

This is not an issue with the 32-bit compiler.

MORE INFORMATION

Sample Code

/* Compile options needed:
Default for a non-MFC Windows DLL (uses /GD)
*/

class _export CTest {
  CTest();
  virtual void vfunc1() {};
};

// Remove the '_inline' in the following line to
// prevent the error.
_inline CTest::CTest() { };


Additional reference words: 1.00 1.50 8.00 8.00c COMDAT
KBCategory: kbtool kbbuglist
KBSubcategory: CPPIss
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.