2014-02-06 88 views
0

我的新MacBook和Mac OS X Mavericks有点问题。 在我的Linux机器上,我的代码编译没有问题,但在我的Mac上,我收到了一些神秘的错误消息,我不明白。g ++无法在Mac OS X上编译小牛队

例如是这样的:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:240:62: error: 
    invalid use of non-static data member '__ptr_' 
explicit __list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} 

有人可以帮我吗?我真的不知道该怎么办...

编辑: 所以...这里是更多的错误日志。这是第一部分。完整的日志太长...

g++ SpinDerivatorController.cpp functions.cpp globalVariables.cpp main.cpp mathFunctions.cpp svd.cpp -o testCompile 
In file included from SpinDerivatorController.cpp:8: 
In file included from ./SpinDerivatorController.h:11: 
In file included from ./SpinOperators.h:11: 
In file included from ./SpinStateTemplate.h:11: 
In file included from ./StateTemplateSimple.h:19: 
./SeriesTemplate.h:217:1: warning: control reaches end of non-void function [-Wreturn-type] 
} 
^ 
./SeriesTemplate.h:314:4: note: in instantiation of member function  'SeriesTemplate<std::__1::complex<double>, 
    ExponentsTemplate<int> >::operator*=' requested here 
    s3*=s2; 
    ^
./StateTemplateSimple.h:444:25: note: in instantiation of function template specialization 
    'operator*<std::__1::complex<double>, ExponentsTemplate<int> >' requested here 
            x += (it1->second) * (it2->second); 
                ^
SpinDerivatorController.cpp:127:24: note: in instantiation of function template specialization 
    'operator*<SeriesTemplate<std::__1::complex<double>, ExponentsTemplate<int> > >' requested here 
        b[k]=(inputStates[j]*outputStates[i]).real(); 
             ^
1 warning generated. 
In file included from functions.cpp:8: 
In file included from ./functions.h:15: 
In file included from ./StateTemplateSimple.h:12: 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:240:62: error: 
    invalid use of non-static data member '__ptr_' 
explicit __list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} 
                 ^~~~~~ 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:240:69: error: 
    use of undeclared identifier '__p' 
explicit __list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} 
                   ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:240:60: error: 
    C++ requires a type specifier for all declarations 
explicit __list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} 
                ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:245:21: error: 
    expected member name or ';' after declaration specifiers 
template<class, class> friend class list; 
       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:245:21: error: 
    C++ requires a type specifier for all declarations 
template<class, class> friend class list; 
       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:245:20: error: 
    expected ';' at end of declaration list 
template<class, class> friend class list; 
      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:263:5: error: 
    expected member name or ';' after declaration specifiers 
{ 
^ 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:240:50: error: 
    expected expression 
explicit __list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} 
              ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__config:289:21: note: 
    expanded from macro '_NOEXCEPT' 
# define _NOEXCEPT throw() 
       ^
./nr3.h:71:59: note: expanded from macro 'throw' 
{printf("ERROR: %s\n  in file %s at line %d\n", message,__FILE__,__LINE__); throw(1);} 
+0

复制并粘贴完整的错误日志。这将告诉我们你从哪里来的。 –

+0

是的...完整的日志太大而无法发布。我将编辑我的帖子并尽可能地放入。问题是我不能产生一个最小代码,它会产生错误:( – Dominik

回答

2

define一上线71这与冲突使用在C++非标准库throw关键字在nr3.h命名throw宏。

一个简单的解决方案是将其他名称命名为宏,如MY_PROJECT_THROW

无论如何,这是一个很好的做法,将所有使用uniqe字符串定义的宏前缀以避免此类名称冲突。

+0

哈哈!这解决了问题:)有趣的是,它在我的Linux机器和以前的Mac OS X版本上没有问题。 – Dominik