c++ - 错误:“_GLIBCXX_TXN_SAFE_DYN”没有命名类型
问题描述
我正在尝试编译一些我在另一台运行 CentOS 的机器上编写的 c++ 代码。我正在尝试在 Ubuntu 16.04 中编译,尽管具有相同版本的 gcc (4.8) 和 clion (2018.3),但代码无法正确编译。错误之一是:
error: '_GLIBCXX_TXN_SAFE_DYN' does not name a type
what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT {
我在互联网上搜索了这个错误或试图弄清楚 _GLIBCXX_TXN_SAFE_DYN 是什么意思,但找不到任何东西。代码仍然可以在 CentOS 机器上正确编译。我可能缺少一些依赖或其他东西,但无法弄清楚。
class TestException : public std::exception {
public:
/*!
* @brief Default constructor to create a new instance of @c TestException
*
* @param what A description of what might have gone wrong in the test
* @param file The file name where the error occurred (i.e. @c __FILE__ )
* @param function The function name in which the error occurred (i.e. @c __FUNCTION__ )
* @param line The line number where the error occurred. (i.e. @c__LINE__ )
*/
TestException(const std::string what, const std::string file, const std::string function, const int line) {
std::stringstream s;
s << "TestException in file \"" << file << "\" in function \"" << function << "\" at line " << line
<< ": " << what;
_msg = s.str();
}
//! @brief Return the error message as a string for use in error messages or tracing
virtual const char*
what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT {
return _msg.c_str();
}
private:
std::string _msg; //!< @brief The formatted message string.
};
解决方案
使用 C++ 7.4.0 编译器或更新版本。我对使用 GNU 5.5.0 的客户也有同样的经历。至少这对我们有用。
-- C 编译器标识为 GNU 7.4.0 -- CXX 编译器标识为 GNU 7.4.0
推荐阅读
- angular - 如何从 mockStore.overrideSelector() 重新分配值?
- python - 在给定数值约束的情况下获取数组索引的广义函数
- swiftui - 地理位置问题 可选
- amazon-web-services - 使用 Docker 和 AWS 将多个服务部署到子域
- javascript - 服务器响应 403
- python - 将字符串匹配到二元组列表
- javascript - 如何按属性减少树节点?
- django - Django:使用 Google Optmize 进行 A/B 测试不起作用
- javascript - (Vuetify) 带有非标签文本的 V-switch
- jenkins - Xray:结果导入任务错误组装问题数据:需要项目