The single backslash, as in C++ code, tells qmake to insert the double quote literally into the string it then places into the DEFINES variable. The value of that variable is placed literally into the Makefile that qmake later generates so that C++ compilations commands get the correct structure for the shell to execute.
// In the PRO file
DEFINES += -DTEST=\"value and space\"
// what ends up in the Makefile
DEFINES = -DTEST="value and space" -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED ...
// So the shell gets this command when you run make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DTEST="value and space" -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED ...
// In the PRO file
DEFINES += -DTEST=\"value and space\"
// what ends up in the Makefile
DEFINES = -DTEST="value and space" -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED ...
// So the shell gets this command when you run make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DTEST="value and space" -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED ...
To copy to clipboard, switch view to plain text mode
If Visual Studio causes the value to be parsed twice then you would need to double the backslashes in order to get the same end result. The pair \\ collapses to a single \, and the pair \" collapses to a double-quote.
// Start with
-DTEST=\\\"value and space\\\"
// after first parser has reduced escaping
-DTEST=\"value and space\"
// after second parsing reduces escaping
-DTEST="value and space"
// which is what you want in your actual compiler command.
// Start with
-DTEST=\\\"value and space\\\"
// after first parser has reduced escaping
-DTEST=\"value and space\"
// after second parsing reduces escaping
-DTEST="value and space"
// which is what you want in your actual compiler command.
To copy to clipboard, switch view to plain text mode
(The exact processing VS does is unknown to me)
Bookmarks