sconsを使用してプログラムを作成すると、次のようなエラーが発生します。
エラー:不明なタイプ名 'constexpr'
エラー:非修飾IDが必要です
Xcodeとxquartzの最新バージョンはすでにインストールされています。これは私のMac clangバージョンです
Apple LLVMバージョン8.1.0(clang-802.0.42)ターゲット:x86_64-Apple-darwin16.6.0スレッドモデル:posix InstalledDir:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
また、念のため、エラーログ全体を添付しました。
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:54:10: error: unknown type name 'constexpr'
static constexpr double pi = 3.1415;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:54:20: error: expected unqualified-id
static constexpr double pi = 3.1415;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:55:10: error: unknown type name 'constexpr'
static constexpr double twopi = 2*pi;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:55:20: error: expected unqualified-id
static constexpr double twopi = 2*pi;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:56:10: error: unknown type name 'constexpr'
static constexpr double halfpi = pi/2;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:56:20: error: expected unqualified-id
static constexpr double halfpi = pi/2;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:57:10: error: unknown type name 'constexpr'
static constexpr double pi2 = pi*pi;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:57:20: error: expected unqualified-id
static constexpr double pi2 = pi*pi;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:62:10: error: unknown type name 'constexpr'
static constexpr double millimeter = 1.;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:62:20: error: expected unqualified-id
static constexpr double millimeter = 1.;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:63:10: error: unknown type name 'constexpr'
static constexpr double millimeter2 = millimeter*millimeter;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:63:20: error: expected unqualified-id
static constexpr double millimeter2 = millimeter*millimeter;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:64:10: error: unknown type name 'constexpr'
static constexpr double millimeter3 = millimeter*millimeter*millimeter;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:64:20: error: expected unqualified-id
static constexpr double millimeter3 = millimeter*millimeter*millimeter;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:66:10: error: unknown type name 'constexpr'
static constexpr double centimeter = 10.*millimeter;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:66:20: error: expected unqualified-id
static constexpr double centimeter = 10.*millimeter;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:67:10: error: unknown type name 'constexpr'
static constexpr double centimeter2 = centimeter*centimeter;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:67:20: error: expected unqualified-id
static constexpr double centimeter2 = centimeter*centimeter;
^
/Users/jeon.hk/Documents/geant4/geant4.10.3-install/bin/../include/Geant4/CLHEP/Units/SystemOfUnits.h:68:10: error: unknown type name 'constexpr'
static constexpr double centimeter3 = centimeter*centimeter*centimeter;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
scons: *** [build/macosx64/rat.o] Error 1
scons: building terminated because of errors.
コメントありがとうございます。
この問題の正しい答えは、c ++ 11サポートを有効にしてコンパイルすることです(clang -std=c++11
)constexprキーワードを認識させるため。