我有一个包含cmath
的C ++程序,并使用它的一些功能(asin
,cos
等)。请注意,如果我使用math.h
在使用我的程序编译时,我获得了许多编译器错误:
In file included from src/measure.cpp:2:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:301:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/math.h:33:1: error: expected unqualified-id
__BEGIN_DECLS
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/sys/cdefs.h:71:30: note: expanded from macro '__BEGIN_DECLS'
#define __BEGIN_DECLS extern "C" {
^
In file included from src/measure.cpp:2:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:321:12: error: use of undeclared identifier '__inline_signbitf'; did you mean '__builtin_signbitf'?
return signbit(__lcpp_x);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/math.h:184:37: note: expanded from macro 'signbit'
( sizeof(x) == sizeof(float) ? __inline_signbitf((float)(x)) \
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:321:12: note: '__builtin_signbitf' declared here
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/math.h:184:37: note: expanded from macro 'signbit'
( sizeof(x) == sizeof(float) ? __inline_signbitf((float)(x)) \
^
In file included from src/measure.cpp:2:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:321:12: error: use of undeclared identifier '__inline_signbitd'
return signbit(__lcpp_x);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/math.h:185:37: note: expanded from macro 'signbit'
: sizeof(x) == sizeof(double) ? __inline_signbitd((double)(x)) \
^
In file included from src/measure.cpp:2:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:321:12: error: use of undeclared identifier '__inline_signbitl'; did you mean '__builtin_signbitl'?
...
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [build/measure.o] Error 1
我正在使用命令编译命令行:
g++ -std=c++11 -g -Wall -I include -c -o build/measure.o src/measure.cpp
感谢您的帮助!