我想构建LLVM clang编译器,但CMake最终会出现以下错误消息:
CMake Error at CMakeLists.txt:256 (message):
Unexpected failure executing llvm-build: Traceback (most recent call
last):
File "C:/.../llvm/utils/llvm-build/llvm-build", line 3, in
<module>
import llvmbuild
File "C:\...\llvm\utils\llvm-build\llvmbuild\__init__.py",
line 1, in
<module>
from main import main
ImportError: No module named main
-- Configuring incomplete, errors occurred!
Run Code Online (Sandbox Code Playgroud)
我已经安装了所有需要的工具.
我有很多(数十万)相当大(>0.5MB)的文件,其中数据是数字,但以逗号作为小数分隔符。使用像 之类的外部工具对我来说是不切实际的sed "s/,/./g"。当分隔符是点时,我只使用textscan(fid, '%f%f%f'),但我看不到更改小数点分隔符的选项。如何有效地读取这样的文件?
文件中的示例行:
5,040000 18,040000 -0,030000
Run Code Online (Sandbox Code Playgroud)
注意: R有类似的问题,但我使用 Matlab。
可能重复:
单元测试编译时错误
我想知道是否有可能编写一种单元测试来验证给定的代码不会编译。
例如,我有一个模板类:
#include <boost/static_assert.hpp>
#include <boost/type_traits/is_base_of.hpp>
struct bar_base {};
template <typename T>
class foo
{
BOOST_STATIC_ASSERT(::boost::is_base_of<T, bar_base>::value);
};
Run Code Online (Sandbox Code Playgroud)
因此,测试应成功完成:
struct bar_derived : bar_base {};
foo<bar_derived> f;
Run Code Online (Sandbox Code Playgroud)
但应该失败:
struct bar_other {};
foo<bar_other> f;
Run Code Online (Sandbox Code Playgroud)
有什么想法如何实现这种行为?(现在,我必须取消注释失败的代码,并手动验证是否存在编译错误-我想避免这种情况)
以下代码(现场演示)在 clang/gcc 上运行良好,但在 icc 和 msvc 上编译失败。
唯一的区别是在 中使用模板参数包class A,而class B显式给出所有模板参数。
什么是正确的行为?代码是否错误?我错过了什么吗?或者只是因为 msvc/icc 不符合标准?
更新
测试的编译器版本:
作品:
不起作用:
代码
#include <unordered_map>
template <class Container>
struct A
{};
// the following won't compile on some compilers (msvc, icc)
template <class... Args> // line 8
struct A<std::unordered_map<Args...>> // line 9
{
};
template <class Container>
struct B
{};
// the following compiles fine
template <class K, class …Run Code Online (Sandbox Code Playgroud)