[Development] qPrintable encoding issues

Thiago Macieira thiago.macieira at intel.com
Fri Feb 28 19:22:02 CET 2014


Em sex 28 fev 2014, às 19:00:20, Olivier Goffart escreveu:
> On Friday 28 February 2014 09:29:53 Thiago Macieira wrote:
> > Em sex 28 fev 2014, às 18:09:36, Olivier Goffart escreveu:
> > > > So:
> > > > 	qDebug("%ls\n", qWPrintable(s));
> > > 
> > > That will not work because sizeof(wchar_t) is 4 on linux.
> > > (and QString::vsprintf wands %ls to be ushort*)
> > 
> > Then we fix QString::vsprintf.
> > 
> > We can use %S, which is an alias for %ls on regular printf.
> 
> Could we just accept plain QString then?  perhaps %q or %qs

No, because that's undefined behaviour.

A pointer to QString might be acceptable, but that also triggers two errors:

QString foo();

	qDebug("%S\n", &foo());

error: taking address of temporary [-fpermissive]
error: format ‘%S’ expects argument of type ‘wchar_t*’, but argument 2 has 
type ‘QString*’ [-Werror=format=]

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list