View Full Version : qDebug() and long long int on WIN
iw2lsi
7th December 2011, 17: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
Giampaolo
BTW using printf("%I64d") instead of qDebug("%I64d") works.
GreenScape
23rd December 2011, 18:05
why not use qDebug this way:
qDebug() << qint64(0x7FFFFFFFFFFFFFFF);
???
iw2lsi
20th March 2012, 15:09
hi
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
Giampaolo
ChrisW67
21st March 2012, 05: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.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.