一个关于wvstreams很怪异的编译问题!

rhy2K3 2008-04-07 03:30:16
我准备交叉编译wvstreams到我的开发板上,但是发现编译下面的文件时老是出问题,不得其解,期望高手提示一二。

template <class RET>
class WvCallbackBase
{
protected:
public:
// Fake is a boring object type that we use for calling our "generic"
// member function pointers. Strangely, it crashes if Fake doesn't
// have a virtual table, so we have an empty virtual function to make it
// happy. (This is all a bit evil, but only because C++ sucks. When
// they pass me a callback, they _know_ which function I want to call; I
// don't need to resolve it at runtime...)
struct Fake { virtual void silly() {} };

// FakeFunc is a completely generic member-function pointer. Actually the
// functions we _really_ call aren't part of the Fake class and probably
// have different parameters, but some hideous typecasts should fix that
// right up.
typedef RET (Fake::*FakeFunc)();
typedef RET (*FakeGlobalFunc)();

Fake *obj;

union {
FakeFunc func;
FakeGlobalFunc globalfunc;
};

WvCallbackBase::WvCallbackBase(void *_obj, FakeFunc _func)
: obj((Fake *)_obj), func(_func)
{ }

WvCallbackBase::WvCallbackBase(FakeGlobalFunc _func)
: obj(0), globalfunc(_func)
{ }

...
};

我的交叉编译器老是提示Fake has not been undeclared,但是使用标准g++编译是没有问题的,请问这是怎么一回事啊?
...全文
308 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
stevenkoh 2010-01-07
  • 打赏
  • 举报
回复
后来通过了吗?我在 wvstreams 4.6 下,修改了 configure 文件可以通过了。把其中的 with_openssl =no 全部替换成 with_openssl=yes
rhy2K3 2008-04-08
  • 打赏
  • 举报
回复
我看了一下, 我交叉编译器的版本比g++的版本还新一些。
g++ -v的信息:

Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)

我的交叉编译器的 g++ -v 后的信息:
Reading specs from /opt/toolchains/uclibc-crosstools_gcc-3.4.2_uclibc-20050502/bin/../lib/gcc/mips-linux-uclibc/3.4.2/specs
Configured with: ../gcc-3.4.2/configure --prefix=/opt/toolchains/uclibc-crosstools_gcc-3.4.2_uclibc-20050502/ --target=mips-linux-uclibc --build=mips-linux --host=mips-linux --enable-target-optspace --disable-nls --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads --infodir=/opt/toolchains/uclibc-crosstools_gcc-3.4.2_uclibc-20050502/info --mandir=/opt/toolchains/uclibc-crosstools_gcc-3.4.2_uclibc-20050502/man --disable-__cxa_atexit --disable-checking --with-arch=mips32
Thread model: posix
gcc version 3.4.2

有哪位高手能看出什么东东来啊
rhy2K3 2008-04-08
  • 打赏
  • 举报
回复
/utils/wvcallback.h:106: error: `Fake' has not been declared
/utils/wvcallback.h:106: error: expected unqualified-id before '*' token
/utils/wvcallback.h:106: error: expected `)' before '*' token
/utils/wvcallback.h:106: error: expected `)' before '*' token
/utils/wvcallback.h: In constructor `WvCallback0<RET>::WvCallback0(RET (*)())':/utils/wvcallback.h:106: error: `FakeGlobalFunc' undeclared (first use this function)/utils/wvcallback.h:106: error: (Each undeclared identifier is reported only once for each function it appears in.)
/utils/wvcallback.h: In member function `RET WvCallback0<RET>::operator()()':
/utils/wvcallback.h:106: error: `obj' undeclared (first use this function)/utils/wvcallback.h:106: error: `Func' undeclared (first use this function)/utils/wvcallback.h:106: error: expected `)' before "func"
/utils/wvcallback.h:106: error: `globalfunc' undeclared (first use this function) /utils/wvcallback.h: In constructor `WvCallback0_bound<RET, T>::WvCallback0_bound(T&, RET (T::*)())':/utils/wvcallback.h:108: error: `Fake' undeclared (first use this function)
/utils/wvcallback.h:108: error: expected primary-expression before ')' token/utils/wvcallback.h:108: error: `Func' has not been declared
/utils/wvcallback.h: At global scope:
/utils/wvcallback.h:111: error: `Fake' has not been declared
/utils/wvcallback.h:111: error: expected unqualified-id before '*' token
/utils/wvcallback.h:111: error: expected `)' before '*' token
/utils/wvcallback.h:111: error: expected `)' before '*' token
/utils/wvcallback.h: In constructor `WvCallback1<RET, P1>::WvCallback1(RET (*)(P1))': /utils/wvcallback.h:111: error: `FakeGlobalFunc' undeclared (first use this function) /utils/wvcallback.h: In member function `RET WvCallback1<RET, P1>::operator()(P1)':
/utils/wvcallback.h:111: error: `obj' undeclared (first use this function)
/utils/wvcallback.h:111: error: `Func' undeclared (first use this function)/utils/wvcallback.h:111: error: expected `)' before "func" /utils/wvcallback.h:111: error: `globalfunc' undeclared (first use this function)
/utils/wvcallback.h: In constructor `WvCallback1_bound<RET,
rhy2K3 2008-04-08
  • 打赏
  • 举报
回复
就相当于声名一个int型,不过这里的类型是函数类型,int也变成了FakeFunc
独孤过儿 2008-04-08
  • 打赏
  • 举报
回复
$ g++ -v

输出结果贴上来
rhy2K3 2008-04-08
  • 打赏
  • 举报
回复

typedef RET (Fake::*FakeFunc)() 应该是定义fake结构体中的返回植类型为RET的函数指针类型。
taodm 2008-04-08
  • 打赏
  • 举报
回复
wvcallback.h是这个东西的派生类吧。
要用WvCallbackBase<XXX>::Fake等。
rhy2K3 2008-04-08
  • 打赏
  • 举报
回复
Supper_Jerry 2008-04-07
  • 打赏
  • 举报
回复
应该就是编译器有关的。
typedef RET (Fake::*FakeFunc)()
指向类成员函数的指针。必须是类成员函数哦。
  • 打赏
  • 举报
回复
编译器的问题吧
myullian 2008-04-07
  • 打赏
  • 举报
回复
指向Fzke成员函数的指针
bestvalentine 2008-04-07
  • 打赏
  • 举报
回复
学习
systemthink 2008-04-07
  • 打赏
  • 举报
回复
关注。。。
icosagon 2008-04-07
  • 打赏
  • 举报
回复
Fake头文件?
ttkk_2007 2008-04-07
  • 打赏
  • 举报
回复
typedef RET (Fake::*FakeFunc)()
=========================
指向类Fake的成员函数的指针,返回RET,参数为空,
jieao111 2008-04-07
  • 打赏
  • 举报
回复
typedef RET (Fake::*FakeFunc)()


成员函数的指针啊。。和typedef void (Fake::*FakeFunc)() 差不多吧。。
rhy2K3 2008-04-07
  • 打赏
  • 举报
回复
自己顶
rhy2K3 2008-04-07
  • 打赏
  • 举报
回复
升级编译器,对于我应该不可行。 typedef RET (Fake::*FakeFunc)() 这几句有没高手解释一下,这种代码写的也忒他nnd的难懂拉吧! 伤心~~~
taodm 2008-04-07
  • 打赏
  • 举报
回复
升级编译器。
要么,你自己想办法去掉模板。

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧