[Qt-interest] What's wrong with this debug Macro

Kermit Mei kermit.mei at gmail.com
Thu Jun 11 07:52:38 CEST 2009


Hello, community!
For convenience, I define a macro to print the debug infomation:

#define DWHERE()                                             \
  qDebug(”##FILE: %s ##LINE: %d  ##FUNC: %s”,                \
         __FILE__, __LINE__, __FUNCTION__);

Macro DWHERE() will print the file, line, and function for me, but it
can't be compiled, why?

$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DDEBUG -DQT_NO_DEBUG
-DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g
++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui
-I/usr/include/qt4 -I. -I. -I. -o Widget.o Widget.cpp
Widget.cpp:27: error: stray ‘\342’ in program
Widget.cpp:27: error: stray ‘\200’ in program
Widget.cpp:27:1: error: pasting "�" and "FILE" does not give a valid
preprocessing token
Widget.cpp:27: error: stray ‘\235’ in program
Widget.cpp:27: error: stray ‘\342’ in program
Widget.cpp:27: error: stray ‘\200’ in program
Widget.cpp:27: error: stray ‘\235’ in program
Widget.cpp: In constructor ‘Widget::Widget(QWidget*)’:
Widget.cpp:27: error: expected primary-expression before ‘:’ token
make: *** [Widget.o] Error 1
$ 

Anything wrong?

Thanks!




More information about the Qt-interest-old mailing list