Re: Parameter Name Warning?

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Michael Kennedy [UB] (mkennedy_at_REMOVETHIS.unitedbinary.com)
Date: 04/13/04


Date: Tue, 13 Apr 2004 12:09:59 -0700

Hi Carl,

Please see my inline comments.

Regards,
Michael

"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@mvps.org.nospam>
wrote in message news:%23TvpOlYIEHA.964@TK2MSFTNGP10.phx.gbl...
> Michael Kennedy [UB] wrote:
> > Victor,
> >
> > Please see the attached image. It's a screenshot from VS.NET 2003. I
> > had to blur out some of the code for intellectual property concerns,
> > but the error is *unmistakable*.
> >
> > Execute this line:
> >
> > CString value = f;
> >
> > Then in the watch window,
> >
> > value != f.
>
> The image you've posted doesn't show enough to conclude that. Clearly
> 'value.m_pszData' is pointing at a different location than 'f', but that's
> to be expected, since the assignment to CString will copy the value.

I think it does show enough code. The CString = does a string copy. The
resultant value of the CString is not equal to the value of the original
string. How could they be the same and have the CString's string value
different from the string value? I'm not talking about the pointer's value
(as indicated by both of us those differ because of the copy). I'm talking
about the text:

CString value = f;

value.GetBuffer() is "2c..."
f is "cc..."

How can that be disputed that the string value of value and the string value
of f are different?

What do you think value == f would return (that is the CString overloaded =
operator)? What do you think it would return if f = "2c" and
value.GetBuffer() = "2c"?

>
> Now, if the contents of those memory locations are different, that
> definitely would indicate something screwy! (Perhaps the contents are
> different, but you didn't show that).
>
> >
> > Note that this class is written as unmanaged C++ but is being used in
> > a managed C++ library. I could not reproduce the error in pure
> > unmanaged C++.
>
> I wonder if you're actually running under the managed debugger at this
> point, and if in managed code the names recorded in the meta-data do in
fact
> come from the declaration of the function and not from the definition as
> they ought to.

I am running under the managed debugger. I think that's the problem. From
how C++ works those variable names should come from the implmentation, not
the header as they are.

> -cd
>
>



Relevant Pages

  • Re: peer code review/advice needed for noob programmer
    ... There are lots of easy ways to transition from char to CString; ... Yes, except I am having to program to Microsoft FS's API, and the string is ... if any reason to allocate a buffer here. ...
    (microsoft.public.vc.mfc)
  • Re: CSocket/CAsyncSocket sending and receiving
    ... Stop experimenting with CSocket; it is losing. ... CString constructor will do a MultiByteToWideChar to convert the string. ... sequence of Receives will receive N bytes. ...
    (microsoft.public.vc.mfc)
  • Re: CFileDialog drives me insane. Handle Problem ?
    ... The basic type you care about is CString. ... This is the equivalent to the Java 'String' ... There are rare cases in which you need a LPTSTR pointer, ... const wchar_t * - const pointer to Unicode characters. ...
    (microsoft.public.vc.mfc)
  • Re: CFileDialog drives me insane. Handle Problem ?
    ... The basic type you care about is CString. ... This is the equivalent to the Java 'String' ... There are rare cases in which you need a LPTSTR pointer, ... const wchar_t * - const pointer to Unicode characters. ...
    (microsoft.public.vc.mfc)
  • Re: peer code review/advice needed for noob programmer
    ... Yes, except I am having to program to Microsoft FS's API, and the string is ... I'm betting that I can take that string and use a CString as ... if any reason to allocate a buffer here. ... Consider a style that uses fixed-size buffers as obsolete programming practice. ...
    (microsoft.public.vc.mfc)