Reputation: 8177
Under Qt5.9 and clang++-6.0.0,
QString ret;
qFatal(ret.toLatin1().constData());
yields a warning "format string is not a string literal".
What's wrong, and what is the right way to accomplish the required conversion from QString to a C string?
PS: A closely related question is Converting QString to char*. Here, however, different solutions are possible thanks to the printf-like argument list of qFatal.
Upvotes: 3
Views: 2186
Reputation: 8177
qFatal
allows for the variadic ...
argument known from printf
. Thus
qFatal("%s", ret.toLatin1().constData());
and the warning is gone.
Upvotes: 2