Problem building old project with VC++ 4.2
Bjarne Madsen -- bhm@image.dk Monday, August 12, 1996 Environment: VC++ 4.2 / Win 95 I have a problem with my Visual C++ 4.2. When I try to build some of my old programs I get a C2664 compiler error. All things worked fine in C++ 4.1. The problem occur in all programs where I use : CTypedPtrListCMyObjectList; F:\MSVC\MFC\include\afxtempl.h(1561) : error C2664: 'struct __POSITION = *CObList::AddHead(class CObject *)' : cannot convert parameter 1 from = 'class CMyObject *' to 'class CObject *' (new behavior; please see help) F:\MSVC\MFC\include\afxtempl.h(1563) : error C2664: 'struct __POSITION = *CObList::AddTail(class CObject *)' : cannot convert parameter 1 from = 'class CMyObject *' to 'class CObject *' (new behavior; please see help) F:\MSVC\MFC\include\afxtempl.h(1587) : error C2664: 'SetAt' : cannot = convert parameter 2 from 'class CDrev *' to 'class CObject *' (new = behavior; please see help) I have read the Technote: Improved Conformance to ANSI C++, but it = dosn't solve my problem. The error message is easy to see, when you build the scribble tutorial. So for short: If you can tell me how to get Scribble step1 to work, I = will be happy. Thank you for your valuable time in advance. Bjarne H=F8j Madsen E-mail: bhm@image.dk
Mike Blaszczak -- mikeblas@nwlink.com Wednesday, August 14, 1996 [Mini-digest: 5 responses] At 08:31 AM 8/12/96 +0200, you wrote: >I have a problem with my Visual C++ 4.2. When I try to build some of >my old programs I get a C2664 compiler error. >All things worked fine in C++ 4.1. The problem you're experiencing is because of a bug in your own code. Since the MFC Libraries, in Version 4.2, were tightened up to catch this bug, you're getting errors from the compiler. >The problem occur in all programs where I use : >CTypedPtrListCMyObjectList; >F:\MSVC\MFC\include\afxtempl.h(1561) : error C2664: 'struct > __POSITION *CObList::AddHead(class CObject *)' : cannot > convert parameter 1 from 'class CMyObject *' > to 'class CObject *' (new behavior; please see help) The cause and solution to this problem were discussed within the last four days on this very same list. Look for messages with a subject line something like "Re: VC4.2 & C2664 problem". The subject line even contains the same error message identifier as the error message you quoted. If you _just_ joined the list, the messages which I'm referring to are available on ftp://advn.com/pub/mfc. >So for short: If you can tell me how to get Scribble >step1 to work, I will be happy. There is no conspiracy. >Thank you for your valuable time in advance. Give me the keys. Thank you for your valuable car in advance. .B ekiM http://www.nwlink.com/~mikeblas <--- trip report central 1995 Honda VFR750F (Serial number 00050!) Four Corners '96! 1987 Yamaha FZ700 (damaged) AMA, HRC, VFROC These words are my own: I do not speak for Microsoft. What's that square thing in my mirror that says "ovloV"? -----From: Stuart Downing This comes up because MFC 4.2 introduces some new entry points to the = template collection classes. Here are two possible solutions to this problem: 1) If you are only using the collection for containment, and you don't = care about serialization, change the BASE_CLASS (CObList) template parameter to CPtrList. 2) If you need serialization support, make sure the compiler knows that = CMyObject is derived from=20 CObject before the declaration of CMyObjectList. The following is not = sufficient... class CMyObject; CTypedPtrList CMyObjectList; Instead... class CMyObject : public CObject {...}; CTypedPtrList CMyObjectList; --------------------------------------------- Stuart Downing stuartd@izzy.net -----From: Milind Changire Hello Bjarne! You MUST have CMyObject derived out of CObject. [There was another posting related to this kind of a problem.] If you haven't derived CMyObject from CObject then I suggest you to do the same. -Milind -----From: Niels Ull Jacobsen The templates in afxtempl.h have been improved. They now require=20 that the CMyObject is CObject-derived instead of casting it blindly.=20 This means that you must give the full declaration of CMyObject before us= ing the template=20 so that the compiler can check that they are CObjects. Niels Ull Jacobsen, Kr=FCger A/S (nuj@kruger.dk) Everything stated herein is THE OFFICIAL POLICY of the entire Kruger=20 group and should be taken as legally binding in every respect.=20 Pigs will grow wings and fly.
| Вернуться в корень Архива |