The information in this article applies to:
SYMPTOMSAfter compiling an application with Microsoft C/C++ for MS-DOS, an attempt to link the application fails and Microsoft LINK generates the following message: After compiling an application with Microsoft C/C++ 32-bit Edition, an attempt to link the application fails and Microsoft LINK generates the following messages:
CAUSEMicrosoft C/C++ compiler version 8.0 and 8.0c for MS-DOS and Windows always uses the __cdecl calling convention for functions declared as follows:
However, if the compiler command line includes the /Gc compiler option
switch, the function has the __pascal calling convention. Normally,
every member function of a class uses the __pascal calling convention
without regard to the presence of the /Gc compiler option switch.
For example, if you build an application with the Microsoft Foundation Class Library and refer to the function CString::operator const char *() const, an L2029 error occurs if you specify the /Gc compiler option switch. Because the Class Library was built without the /Gc option, the conversion function in the library has the __cdecl calling convention. If you build your application with the /Gc option switch, it attempts to call the conversion function with the __pascal calling convention. A similar problem occurs in Microsoft C/C++ 32-bit Edition if you specify the /Gz compiler option switch. Normally, each class member function uses the thiscall calling convention without regard to the presence of the /Gz compiler option switch. However, if the compiler command line specifies the /Gz compiler option switch, the conversion function uses the __stdcall calling convention. RESOLUTIONIn Microsoft C/C++ version 8.0 for MS-DOS and Windows, modify the compiler command line to remove the /Gc compiler option switch. Doing so compiles the conversion function with the __cdecl calling convention. In Microsoft C/C++ version 8.0 (32-bit), modify the compiler command line to remove the /Gz compiler option switch. Doing so compiles the conversion function with the thiscall calling convention. STATUSMicrosoft has confirmed this to be a bug in the products listed at the beginning of this article. This bug was corrected in Visual C++ version 2.0. MORE INFORMATION
The code example below demonstrates this problem. Recall that because
member functions use the __pascal or thiscall calling convention,
compiling MAIN.CPP with the /Gc or /Gz switches specified or not
should not make any difference. However, the example shows that a
problem does occur.
Sample Code
Additional query words: 1.00 1.50 8.00 8.00c
Keywords : kbCompiler kbCPPonly kbVC |
Last Reviewed: February 2, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |