gpt4 book ai didi

c++ - 在 mac os x 中制作期间出现错误未知类型名称 'constexpr'

转载 作者:可可西里 更新时间:2023-11-01 17:44:21 30 4
gpt4 key购买 nike

当我使用 scons 编写一些程序时,会发生类似这样的错误,

error: unknown type name 'constexpr'

error: expected unqualified-id

我已经安装了最新版本的 xcode 和 xquartz。这是我的 mac clang 版本

Apple LLVM version 8.1.0 (clang-802.0.42)Target: x86_64-apple-darwin16.6.0Thread model: posixInstalledDir: /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 关键字。

关于c++ - 在 mac os x 中制作期间出现错误未知类型名称 'constexpr',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45047508/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com