RE: ATL::CString doesn't have conversion operator for LPTSTR...
"Michael Stephenson" <[email protected]> Fri, 10 Jun 2011 03:35:16 -0400
| Newsgroups | gmane.comp.windows.wtl |
|---|---|
| Message-ID | <[email protected]> |
As a note, the "canonical" way to convert a CString to an LPTSTR has been to double cast it via (LPTSTR)(LPCTSTR) or something similar using the C++-specific cast expressions. This should, of course, only be done if you are sure you are not going to alter the string. -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Richard B. Sent: Thursday, June 09, 2011 7:35 PM To: [email protected] Subject: Re: [wtl] ATL::CString doesn't have conversion operator for LPTSTR... You are right - it should be LPCTSTR. Problem solved - I was including atlstr.h after all other ATL/WTL includes. When I placed it earlier, after atlbase.h, the compilation error disappeared. Best Regards, Richard B. On 09/06/2011 23:52, Anna-Jayne Metcalfe wrote: > Hi Richard, > > > While playing around with DDX and WTL, I got a compilation error > for the DDX_TEXT macro saying "cannot convert parameter 2 from > 'ATL::CString' to 'LPTSTR'". > > > I would prefer to keep using ATL's CString, and modifying atlstr.h > to add a LPTSTR conversion operator is obviously not ideal, so any > ideas on how best to handle this ? > > I've not seen this with DDX. > > Without digging through the code I can't be sure, but surely with > LPTSTR being a non-const type adding a conversion operator would be > dangerous at best. > > operator LPCTSTR() is of course a different beast entirely. That's > definitely there - I use it all the time. > > Or am I missing something? (possible - it's nearly midnight and I'm > about to crash). > > Kind Regards, > > Anna-Jayne Metcalfe > Product Manager, > Riverblade Limited > > http://www.riverblade.co.uk > > Riverblade Limited, 3 Wellington Road, Bournemouth, Dorset BH8 8JQ, > United Kingdom Registered in England no. 5187132. VAT Registration no. > 847 0045 38 Please direct general enquiries to > [email protected] <mailto:enquiries%40riverblade.co.uk>. > > ACCU 2012 - http://www.accu.org/conference - 24-28th April 2012, Oxford UK. > > ------------------------------------ Yahoo! Groups Links ------------------------------------ Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/wtl/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/wtl/join (Yahoo! ID required) <*> To change settings via email: [email protected] [email protected] <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/