Re: HEEELP CRgn copy?
From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 11/06/04
- Next message: Joseph M. Newcomer: "Re: Saving CStrings to file"
- Previous message: Joseph M. Newcomer: "Re: Spy++ mystery"
- In reply to: Lisa Pearlson: "Re: HEEELP CRgn copy?"
- Next in thread: Lisa Pearlson: "Re: HEEELP CRgn copy?"
- Reply: Lisa Pearlson: "Re: HEEELP CRgn copy?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 06 Nov 2004 18:22:20 -0500
Yes, this is actually a typical sort of bug that Microsoft has. Even in the case where the
object is not being modified, they forgot to include the 'const' attribute on the
parameter. CopyRgn SHOULD have had 'const' on it, and the fact that it does not is a
mistake. Microsoft has never really understood 'const', and fails to use it where it is
required. They also do things like claim a parameter or return value is a UINT and then
claim that "-1" is a valid return value. But you can't write
DWORD value = someAPI();
if(value == -1)
because the compiler rightly complains about a signed vs. unsigned test. This is a common
problem, and of course to maintain backward compatibility, they won't fix the bugs.
joe
On Sat, 6 Nov 2004 12:33:56 +0100, "Lisa Pearlson" <no@spam.plz> wrote:
>I have another weird problem.
>
>I am passing my parameters to the constructor and assignment operator as a
>'const' object.
>I then have to cast this back to a non const (CRgn*) to pass it to CopyRgn.
>
>CNamedRgn& operator= (const CNamedRgn& nr) {
> ...
> rgn.CopyRgn((CRgn*)&nr);
> ..
>}
>
>But if I remove the const, so I don't have to cast it in CopyRgn, I actually
>get a compile error:
>
>c:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(86) :
>error C2679: binary '=' : no operator defined which takes a right-hand
>operand of type 'const struct tagMapRegion' (or there is no acceptable
>conversion)
> c:\program files\microsoft visual
>studio\vc98\mfc\include\afxtempl.h(406) : see reference to function template
>instantiation 'void __stdcall CopyElements(struct tagMapRegion *,const
>struct tagMapRegion *,int)' being compiled
>
>
>I am not passing a const.. so it seems CopyElements (underlying code to
>CopyRgn I guess) does as shown in the last line above. Yet CopyRgn doesn't
>expect const. Weird?
>
>Lisa
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
- Next message: Joseph M. Newcomer: "Re: Saving CStrings to file"
- Previous message: Joseph M. Newcomer: "Re: Spy++ mystery"
- In reply to: Lisa Pearlson: "Re: HEEELP CRgn copy?"
- Next in thread: Lisa Pearlson: "Re: HEEELP CRgn copy?"
- Reply: Lisa Pearlson: "Re: HEEELP CRgn copy?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|