View Full Version : qDebug() and long long int on WIN

7th December 2011, 18:37
Hi all

I'm in trouble trying to print a long long int with qDebug...
it works fine on linux but on windows 7 + mingw "%lld" is not recognized and "%I64d" crash the application ...

anyone else is having this issue ?

thanks in advance for any hints


BTW using printf("%I64d") instead of qDebug("%I64d") works.

23rd December 2011, 19:05
why not use qDebug this way:

qDebug() << qint64(0x7FFFFFFFFFFFFFFF);


20th March 2012, 16:09

this works... thanks

anyway... I was hoping qDebug() to be more portable... as streaming format insert spaces between items, auto cr/lf at the end etc etc...

Best Regards


21st March 2012, 06:47
Ultimately the qDebug(const char *fmt, ...) uses QString::sprintf():

The format string supports most of the conversion specifiers provided by printf() in the standard C++ library. It doesn't honor the length modifiers (e.g. h for short, ll for long long). If you need those, use the standard snprintf() function instead...

Also see: bug report (https://bugreports.qt-project.org/browse/QTBUG-23078)

You can suppress spaces in the streamed version:

qDebug() << "1" << "2" << "3";
qDebug().nospace() << "1" << "2" << "3";

QDebug is a debugging aid, not a pretty printer, but nothing stops you using QString and QString::arg() to build more complex output.