PRB: Conflict with EOF When Using #import with ADOID: Q166112
|
With #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 <msado15.dll>
error C2629: unexpected 'short ('
error C2238: unexpected token(s) preceding ';'
Within an application that uses Stdio.h, Ios.h or Streamb.h
(including Afxwin.h), EOF has already been defined as a constant
(-1). The #import then attempts to define the EOF property for ADO's Recordset or RDO's Resultset objects, and generates the C2629/C2238 errors on the following line of generated code in the Msado10.tlh file:
VARIANT_BOOL EOF;
short -1;
To correct this, you can use the rename attribute of #import as follows:
#import <msado15.dll>
rename( "EOF", "A_EOF" )
#undef EOF
#import <msado15.dll> rename_namespace("ADO20")
This behavior is by design.
Additional query words: kbdsd KBadovc
Keywords : kbprg kbDatabase
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: March 12, 1999