Microsoft KB Archive/114153

From BetaArchive Wiki

BUG: Class Export with Inline Constructor Causes L2022

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 " 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
Issue type :
Technology :


Last Reviewed: December 22, 1999
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.