VT_BOOL throws compilation error in VC++4.2
Ramachandra Rao -- chandu@ampersand.soft.net Wednesday, December 11, 1996 Environment: VC++ 4.2-flat, NT 3.51 Hi While porting my application from VC++4.0 to VC++ 4.2, I get compilation errors as follows - Warning: Non standard extension used : 'bool' keyword is used for future use. Error : bool is not a member of COleVariant. Surprisingly, the VC++ 4.2 help states that bool is a member of VARIANT structure of type VT_BOOL. My usage of the bool is as follows. I retrieve some data from the database using CDaoRecordset.GetFieldValue() which returns an object( say MyVariant) of type COleVariant.Now to get the value from MyVariant object I do switch(MyVariant.vt) { case VT_BOOL: BOOL bValue = MyVariant.bool; break; } This piece of code works fine in VC++ 4.0. Can someone explain why this happens and what is to be done in 4.2 so that I can achieve my functionality. Thanks Chandu
GoroKhM1 -- gorokhm1@SMTP.ATG-NET.COM Friday, December 13, 1996 [Mini-digest: 5 responses] The answer: inline BOOL F_VarToBool(COleVariant& v) { return (v.vt == VT_BOOL) ? v.boolVal : FALSE; } // F_VarToBool() That function is working fine in VC 4.2b (the prototype is from DAOSDK\SAMPLES\EMPLOYEE\DAOEMP.H) MarkG@usa.net ______________________________ Reply Separator _________________________________ Subject: VT_BOOL throws compilation error in VC++4.2 Author: mfc-l@netcom.com at INTERNET Date: 12/13/96 3:32 PM Environment: VC++ 4.2-flat, NT 3.51 Hi While porting my application from VC++4.0 to VC++ 4.2, I get compilation errors as follows - Warning: Non standard extension used : 'bool' keyword is used for future use. Error : bool is not a member of COleVariant. Surprisingly, the VC++ 4.2 help states that bool is a member of VARIANT structure of type VT_BOOL. My usage of the bool is as follows. I retrieve some data from the database using CDaoRecordset.GetFieldValue() which returns an object( say MyVariant) of type COleVariant.Now to get the value from MyVariant object I do switch(MyVariant.vt) { case VT_BOOL: BOOL bValue = MyVariant.bool; break; } This piece of code works fine in VC++ 4.0. Can someone explain why this happens and what is to be done in 4.2 so that I can achieve my functionality. Thanks Chandu -----From: Mike BlaszczakAt 10:01 12/11/96 +0530, Ramachandra Rao S wrote: >Environment: VC++ 4.2-flat, NT 3.51 Please upgrade to 4.2B. It'll only be a matter of time before you run into problems because you're using an outdated and unsupported version of the product. >Hi > While porting my application from VC++4.0 to VC++ 4.2, I get >compilation errors as follows - >Warning: Non standard extension used : 'bool' keyword is used for >future use. >Error : bool is not a member of COleVariant. bool isn't a member of COleVariant. boolVal is, though. > Surprisingly, the VC++ 4.2 help states that bool is a member of >VARIANT structure of type VT_BOOL. My usage of the bool is as follows. Unfortunately, the online help is provided by the SDK guys, and they're pretty slow to get things fixed. > I retrieve some data from the database using >CDaoRecordset.GetFieldValue() which returns an object( say MyVariant) >of type COleVariant.Now to get the value from MyVariant object I do >switch(MyVariant.vt) >{ > case VT_BOOL: > BOOL bValue = MyVariant.bool; > break; >} You shouldn't directly reference members of variants. Instead, you should use the V_macros to get the items. If you had used V_BOOL here, like you should have, you never would have run into this problem. >This piece of code works fine in VC++ 4.0. Can someone explain why this >happens and what is to be done in 4.2 so that I can achieve my >functionality. The compiler in Visual C++ 4.2 reserves the keyword "bool" because it is a first step towards compatibility for this new data type, which was mandated by changes to the ANSI C++ UnStandard. Some system headers were changed, including OLEAUTO.H, where VARIANT is defined. OLEAUTO.H also defines macros for helping you access the members within VARIANT structures. You should use those instead of directly using the structure members. .B ekiM http://www.nwlink.com/~mikeblas/ I'm afraid I've become some sort of speed freak. These words are my own. I do not speak on behalf of Microsoft. -----From: Phil Daley At 10:01 AM 12/11/96 +0530, Ramachandra Rao S wrote: >While porting my application from VC++4.0 to VC++ 4.2, I get compilation errors as follows - >Warning: Non standard extension used : 'bool' keyword is used for future use. >Error : bool is not a member of COleVariant. 4.2 added additional warnings Add a line to your base header file saying something like: #pragma warning (disable:4237) // Turn bool type warnings off BTW: this is a "warning" not an "error" Phil Daley < Relay Technology > http://www.conknet.com/~p_daley -----From: Matt McConnell > While porting my application from VC++4.0 to VC++ 4.2, I get >compilation errors as follows - >Warning: Non standard extension used : 'bool' keyword is used for >future use. >Error : bool is not a member of COleVariant. > I've had this problem too. I think the member is changed to 'boolVal' or some derivation of that. The program I used it in is at work so I can't be sure. Hope this helps. Matt McConnell ---------------------------------- Matt McConnell (KC8AWM) Phi Kappa Psi (Ohio Epsilon) Case Western Reserve University Dept of Electrical Engineering and Applied Physics -----From: "Smith, Brad P." >> Warning: Non standard extension used : 'bool' keyword is used for future use. >Error : bool is not a member of COleVariant. << > "bool" is now a reserved word. So the class structure (stored in AFXDB.H) uses "boolVal". I looked in the VC 4.2 docs for C4237 (which is the error you were getting), and the last paragraph says: --- cut here --- If you include the header OAIDL.H, note that this header defines both bool and boolval. To avoid this warning and prevent possible compatibility problems with future versions of Visual C++, your code should use the boolval definition instead of the bool definition. --- cut here --- Note that OAIDL.H is probably being included by one of the other #includes in your code. Note now that this paragraph is *also* incorrect, and that the *correct* definition to use is boolVal (upper-case 'V'). So, in your code replace: > BOOL bValue = MyVariant.bool; with > BOOL bValue = MyVariant.boolVal; and all will be well. :-) Brad.
| Вернуться в корень Архива |