简体   繁体   English

如何使用C ++ 11构建包含常量表达式的代码

[英]How to build code that contains constant expression with c++11

Hello I am testing new c++ library : TagParser from Martchus https://github.com/Martchus/tagparser I am getting that error when I compile the following code: 您好,我正在测试新的c ++库:来自Martchus的TagParser https://github.com/Martchus/tagparser我在编译以下代码时遇到此错误:

CODE: 码:

#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;

...

ERROR: 错误:

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.

When I try to build with the -std=c++11 option I get this error: 当我尝试使用-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
 }

I really don't know how to solve this. 我真的不知道该怎么解决。 Can anyone help me? 谁能帮我?

Many thanks to Daniel H. When I use c++14 instead of c++11 it just works fine. 非常感谢DanielH。当我使用c ++ 14而不是c ++ 11时,它运行良好。

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM