Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt - getting "warning: format not a string literal and no format arguments"

Keep getting warnings on lines like these

qDebug("An error occured while trying to create folder " + workdir.toAscii());

workdir being QString()

warning: format not a string literal and no format arguments
like image 830
David Polák Avatar asked Nov 25 '10 20:11

David Polák


2 Answers

That should probably be:

qDebug("An error occured while trying to create folder %s", workdir.constData());

since qDebug takes const char* as first argument.

like image 177
Nikolai Fetissov Avatar answered Nov 04 '22 17:11

Nikolai Fetissov


When debbuging with qDebug, I find the following syntax much easier :

qDebug() << "An error occured while trying to create folder" << workdir;

To do this, you'll need to include the <QtDebug> header.

More info : Qt docs regarding qDebug().

like image 41
Jérôme Avatar answered Nov 04 '22 16:11

Jérôme