On Tue, Nov 03, 2009 at 06:49:35PM -0300, Martín Sebastián Wain wrote:
> Damn, I have it like that in a million places =(
> What's weird is that in MSVC++ works with strings. I found Xcode to be a bit
> bitchy
> when it comes to resolving casting operators.
"works" is relative. Make it run on 64bit and watch it explode. :)
But yeah, on a MSVC environment people don't tend to have such trouble
probably since all they care about is 32bit x86 only anyway...
Andreas Mohr
Variadic functions don't apply cast operators. Hence the reason you should NEVER pass non-pod data. (CStrings are currently written in such a way that they "happen" to work)
>
> "works" is relative. Make it run on 64bit and watch it explode. :)
Heck, the next release of the compiler could cause fireworks too! That's the fun of undefined behavior. It's undefined! (just cause it looks like it works now, doesn't mean it will tomorrow) (and I really wish MS had that non-pod type warning - it's extremely useful!)
Dave
MSW> Hi, I'm completly lost here. I'm getting errors on wxLog*() calls.
MSW> I'm still a newbie with Mac, but apparently this has something to do with
MSW> "..."
MSW> parameters.
MSW> I thought that wxLog* functions used a bunch of template definitions (with
MSW> 1, 2, 3... etc parameters) to avoid varadic "..." parameters' weird
MSW> behaviour when passing wxStrings, and such.
This is true for the trunk (i.e. 2.9) but not for 2.8.
Also, the behaviour is not weird -- it's undefined. This (unfortunately
IMO) means that it might even work and Microsoft went to special trouble in
their CString implementation to make it work when passed by value to a
vararg function (apparently this was simpler than teaching C++ to all MFC
users).
MSW> The compiler throws a warning that says:
MSW> warning: cannot pass objects of non-POD type 'struct std::basic_string
MSW> <wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >'
MSW> through '...'; call will abort at runtime
This warning seems admirably clear to me. You need .c_str() when passing
wxStrings to vararg functions (but you don't need it with any previously
vararg functions in 2.9 because they're not vararg any more).
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/