简体   繁体   中英

g++ does not compile on Mac OS X Mavericks

I've got a little problem with my new MacBook and Mac OS X Mavericks. On my Linux Machine my code compiles without problems, but on my Mac I get cryptic error messages I do not understand.

For example something like this:

/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) {}

Can someone please help me? I have really no idea what to do...

EDIT: So... Here is more from the error log. It's the first part. The full log is too long...

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);}

You define a macro named throw in nr3.h on line 71. This clashes with the use of the throw keyword in the c++ standart library.

An easy solution would be to name the macro something else, like MY_PROJECT_THROW .

It is anyway a good practice to prefix all macros you define with a uniqe string to prevent such name clashes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM