I am compiling a QTGUI Application (version 4) with my own GNU makefile. Everything worked nice when I used the C++03 standard with the gcc compiler.
Now I need the C++11 standard and get the error:
unable to find string literal operator 'operator"" __ FILE__' "
at the following lines in my window.cpp
connect(ui->myGLWidget, SIGNAL(xRotationChanged(int)), ui->rotXSlider, SLOT(setValue(int)));
connect(ui->myGLWidget, SIGNAL(yRotationChanged(int)), ui->rotYSlider, SLOT(setValue(int)));
connect(ui->myGLWidget, SIGNAL(zRotationChanged(int)), ui->rotZSlider, SLOT(setValue(int)));
I tried to compile my .ui file with the UIC version 4 and 5 and nothing changed. The result of the UIC, ui_window.h has the same errors whenever Qbject::connect(.....) is used.
I can't go back to the old C++ standard and both UIC compilers produces the same ui_window.h file.
How can I get rid of it?
Before C++11, the syntax "foo"__FILE__
would compile as "foo""filename.cpp"
, resulting in the concatenated string "foofilename.cpp"
. C++11 added a new feature, user-defined string literals, that uses suffixes at the end of a string literal "foo"_bar
to perform a conversion of the string "foo"
to some other type. As a consequence, "foo"__FILE__
now compiles as an attempt to invoke the user-defined string literal operator __FILE__
on "foo"
.
Presumably SIGNAL
and SLOT
are both macros on the source lines indicated - I know little about QT - and one or both of their expansions result in "foo"__FILE__
being present after preprocessing, resulting in the error you observe. If upgrading to a more recent QT is not an option for you, you could trace the definition of the MACROS and ensure there is a space between the tokens resulting in the "foo"__FILE__
. Simply inserting a space may be sufficient, but if the macro definitions involve heavy token-pasting then sometimes forcing a token break with a comment /**/
is needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With