如何构建包含C 11的恒定表达式的代码
How to build code that contains constant expression with c++11
你好,我正在测试新的C 库:Martchus的Tagparserhttps://github.com/martchus/tagparser编译以下代码时,我会遇到错误:
代码:
#include <tagparser/mediafileinfo.h>
#include <tagparser/diagnostics.h>
using namespace TagParser;
// create a MediaFileInfo for high-level access to overall functionality of the library
MediaFileInfo fileInfo;
// create container for errors, warnings, etc.
Diagnostics diag;
...
错误:
In file included from /usr/include/c++/5/cstdint:35:0,
from /usr/local/include/c++utilities/conversion/types.h:4,
from /usr/local/include/tagparser/tagtarget.h:6,
from /usr/local/include/tagparser/settings.h:4,
from /usr/local/include/tagparser/abstractcontainer.h:5,
from /usr/local/include/tagparser/mediafileinfo.h:4,
from TagParserTest.cpp:1:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error:
#error This file requires compiler and library support for the ISO C++ 2011 standard.
This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
当我尝试使用-std=c++11
选项构建时,我会得到此错误:
In file included from /usr/local/include/tagparser/abstractcontainer.h:5:0,
from /usr/local/include/tagparser/mediafileinfo.h:4,
from TagParserTest.cpp:1:
/usr/local/include/tagparser/settings.h: In function ‘constexpr TagParser::TagCreationFlags& TagParser::operator|=(TagParser::TagCreationFlags&, TagParser::TagCreationFlags)’:
/usr/local/include/tagparser/settings.h:53:1: error: expression ‘(lhs = ((TagParser::TagCreationFlags)(((std::underlying_type<TagParser::TagCreationFlags>::type)lhs) | ((std::underlying_type<TagParser::TagCreationFlags>::type)rhs))))’ is not a constant-expression
}
我真的不知道该如何解决。谁能帮我?
非常感谢丹尼尔·H。当我使用C 14代替C 11时,它可以正常工作。
谢谢。
相关文章:
- 编写了一个C++代码来检查表达式是否具有平衡括号并且我的代码未运行.我已经卡了一天了
- 错误:'int'之前的预期主表达式以及代码中的许多类似错误
- C++:正则表达式匹配代码,打印多个匹配项?
- 代码样式:在 switch/if 语句的分支中重用控件表达式或控制变量
- 正则表达式代码无缘无故停止工作
- 如何构建包含C 11的恒定表达式的代码
- 我可以进一步简化此代码/表达式吗?
- 正则表达式C 代码
- 正则表达式捕获会使代码崩溃
- 我在C++文件中的简单代码块上有 2 个错误。错误 C2059:语法错误:"?"。第二智能感知:预期表达式。怎么了?
- Lambda 表达式等效于 C++ 代码
- 中缀到后缀表达式转换代码不起作用
- 将使用正则表达式缩短/美化代码重写它
- 在编写gawk代码时区分除法和正则表达式
- 代码块引发有关for_each的预期主表达式错误
- 我的代码出现错误:错误:“”之前应为主表达式代币
- 如何使用表达式命名 int,以便代码将生成给定数量的整数并命名它们 (c++)
- 是否可以构造与 3 个或更多非连续 UTF 代码点匹配的 PCRE UTF-8 正则表达式
- 为什么使用"cmatch"的C++正则表达式代码会引发"smatch"异常?
- 表达式模板与手写代码