PRB: Conflict with EOF When Using #import with ADOLast reviewed: January 30, 1998Article ID: Q166112 |
The information in this article applies to:
SYMPTOMSWith #import, it is possible to generate classes that encapsulate the typelib of database API's, such as ActiveX Data Objects (ADO), within a windows application. For example:
// Excerpt from Stdafx.h #include <afxwin.h> // MFC core and standard components ... #import "C:\Program Files\Common Files\System\ADO\Msado10.dll"When doing so, you may receive the following errors from the #import for ADO on the Recordset.EOF property:
error C2629: unexpected 'short (' error C2238: unexpected token(s) preceding ';'NOTE: The same error occurs with ADO version 1.5 using Msado15.dll.
CAUSEWithin an application that uses STDIO.H, IOS.H or STREAMB.H (including AFXWIN.H ), EOF has already been defined as a constant (-1). #import then attempts to define the EOF property for ADO's Recordset or RDO's Resultset objects, and generates the C2629/C2238 errors on this line of generated code in the MSADO10.TLH file:
VARIANT_BOOL EOF;This line is attempting to define a variable, but EOF has already defined it as -1. As a result, this line of code parses to:
short -1;This does not compile because -1 is not a valid variable name.
RESOLUTIONTo correct this, you can use the rename attribute of #import as shown below:
#import "C:\Program Files\Common Files\System\ADO\msado10.dll" \ rename( "EOF", "A_EOF" )Rename changes the name of any "EOF" string that #import finds in the specified typelib to a new value. NOTE: When you use ADO version 1.5, replace Msado10.dll with Msado15.dll.
Keywords : kbprg adoengall adoengdb adovc MfcDatabase Version : 5.0 Platform : NT WINDOWS Issue type : kbprb |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |