当我试图创建一个宽正则表达式时,Clang打印一个奇怪的错误(std::花圈)
#include <regex>
#include <string>
int main() {
std::wregex myRegex( L"Hello Regex" );
return 0;
}
使用g++ (--std=c++11 -Wall)编译很好,没有任何错误或警告,但是clang++ (-std=c++11)生成此错误:
In file included from test.cpp:1:
In file included from /usr/bi
我的项目是在Windows (vc++17)上构建的,而且我对Linux也是新手,所以我不知道发生了什么。
我为我的项目创建了CMakeLists文件(带有C++17需求),生成了makefile,然后我使用make尝试在Linux上构建它。错误是:
/home/julien/source/zipfs/zipfs/include/zipfs/zipfs_assert.h:30:70: error: no matching function for call to ‘std::exception::exception(<brace-enclosed initializer list>
我正在为多个平台(Windows、Linux、Mac )开发一个应用程序,我想确保我的代码符合C++标准。在Linux和Mac上,它是通过-pedantic-errors标志、/Za标志(禁用语言扩展)实现的。问题是,一些Windows与C++不兼容(而且以一种愚蠢的方式,没有什么主要的错误是'$' : unexpected in macro definition、'__forceinline' not permitted on data declarations和类似的胡说八道)。你认为有可能修复标头吗?有人试过吗?
由于isnan既可以是宏(在C++98中),也可以是在命名空间std中定义的函数(在C++11中),因此这个简单的示例说明了编写在这两种情况下工作的代码的一种显而易见(也可能很幼稚)的方法。
#include <cmath>
int main() {
double x = 0;
using namespace std;
isnan(x);
}
但是,编译它会出现GCC (使用-std=c++11)和Clang的错误:
test.cc: In function ‘int main()’:
test.cc:6:10: error: call of overloaded ‘