2009-07-16 94 views
0

我正在尝试使用以下代码编译目标文件。使用Sun Studio 12移植到Solaris SPARC

//--Begin test.cpp 
class A; 

void (A::* f_ptr)(); 

void test() { 
    A *a; 
    (a->*f_ptr)(); 
} 
//-- End test.cpp 

对于GNU g ++编译器,它能够编译目标文件。

$ g++ -c test.cpp

但对于太阳录音室12在Solaris 10(SPARC),它输出一个错误。

$ CC -c test.cpp

"test.cpp", line 7: Error: Cannot call through pointer to member function before defining class A.

1 Error(s) detected.

是否有一个编译器标志得到了Sun Studio C++编译器来构建 目标文件?是否有另一种解决方法?

回答

2

尝试到该文件中的#include <A.h>。编译器需要知道什么是class A

0

你会发现有很多事情g ++可以让你逃避sunpro会抱怨,反之亦然。

准备好了很多这样的事情。

GMan的回答对我来说很合适。