开发者

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());

wor开发者_开发知识库kdir being QString()

warning: format not a string literal and no format arguments


That should probably be:

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

since qDebug takes const char* as first argument.


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().


I managed to get it to work fine without warning like this :

qDebug("An error occurred while trying to create folder %s", qUtf8Printable(workdir));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜