[Qt-interest] errors about the macro in QWidget declare file

iptton iptton at gmail.com
Sat May 16 09:48:33 CEST 2009


hello  list.
I am now meet a problem:
consider the follow files:
==============================
macro.h:
==============================
      #ifndef MACRO_H
      #define MACRO_H
            define NAMESPACE  fxgui
            define FX_BEGIN_NAMESPACE  namespace NAMESPACE {
            define FX_END_NAMESPACE      }
            define FX_USING_NAMESPACE  using namespace NAMESPACE ;
     #endif

==============================
mywidget.h
==============================
#ifndef ...
...

#include "macro.h"
FX_BEGIN_NAMESPACE
class MyWidget:public QWidget{
     Q_OBJECT
public:
         ...............
};
FX_END_NAMESPACE
============================
and the rest of mywidget.cpp ommited.
============================

the problem's : when I use FX_BEGIN_NAMESPACE , the copiler ouput :  (just
translate few line )

moc_mywin.cpp:38: error: ‘MyWin’ undeclared
moc_mywin.cpp:43:  error: ‘MyWin’undeclared
moc_mywin.cpp:43: 错误: none-member function ‘const QMetaObject* metaObject()’
couldnot have  cv
moc_mywin.cpp:48: 错误: ‘MyWin’undeclared
moc_mywin.cpp: In function ‘void* qt_metacast(const char*)’:
moc_mywin.cpp:52: 错误: expected type-specifier before ‘MyWin’
moc_mywin.cpp:52: 错误: expected `>' before ‘MyWin’
moc_mywin.cpp:52: 错误: expected `(' before ‘MyWin’
moc_mywin.cpp:52: 错误: ‘MyWin’在此作用域中尚未声明
moc_mywin.cpp:52: 错误: expected primary-expression before ‘>’ token
moc_mywin.cpp:52: 错误: 在非成员函数中使用‘this’无效
moc_mywin.cpp:52: 错误: expected `)' before ‘;’ token
moc_mywin.cpp:53: 错误: 没有对象无法调用成员函数‘virtual void* QWidget::qt_metacast(const
char*)’
moc_mywin.cpp: At global scope:
moc_mywin.cpp:56: 错误: ‘MyWin’未声明
moc_mywin.cpp: In function ‘int qt_metacall(QMetaObject::Call, int,
void**)’:
moc_mywin.cpp:58: 错误: 没有对象无法调用成员函数‘virtual int
QWidget::qt_metacall(QMetaObject::Call, int, void**)’

but when I just use  " namespace fxgui{  " instead of  the macro
FX_BEING_NAMESPACE and "}" of FX_END_NAMESPACE.  It's hasn't not any error!

can any body tell me why?thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090516/204c3e81/attachment.html 


More information about the Qt-interest-old mailing list