lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Christian,

Yes! There is an implicit conversion to a char* since the function is declared as returning LPCTSTR. That Microsoftism translates as "Long pointer to a constant C character string, using wide-char if enabled". So I did *exactly* what you said---I forgot about the implicit conversion of the CString, so the temporary char string got lost. As I said, Ugh!

Michael

----- Original Message ----- From: "Christian Vogler" <Christian.Vogler@gallaudet.edu>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Wednesday, February 02, 2005 1:20 PM
Subject: Re: Q on functions as first class values


On Wednesday 02 February 2005 03:10 pm, Michael Newberry wrote:
I think I just recognized my own problem  (cause by the other problem:
"coding + coffee + sleep = constant"). I violated a rule I preach all the
time, about not pushing volatile things on the stack!!! That CString s is
not persistent. Ugh! Sorry to waste people's time!

Don't be too hard on yourself ... I think this example rather demonstrates the
dangers of a class design that does unsafe implicit type conversions. Is
CString a class with an implicit conversion to char *? If yes, that is where
the real problem lies.

(I assume that char * is what LPCTSTR is supposed to be? - I am no longer up
to speed with respect to Microsoft's weird naming convention)

Regards
- Christian