草庐IT

c++ - 为什么字符串连接宏不适用于这个 "+"案例?

小问题:是否允许为字符串连接宏##连接特殊符号,例如+、-?例如,#defineOP(var)operator##varOP(+)会扩展为operator+吗?具体问题:#include"z3++.h"#includenamespacez3{z3::exproperator+(z3::exprconst&,z3::exprconst&);}typedefz3::expr(*MyOperatorTy)(z3::exprconst&,z3::exprconst&);#defineSTR(var)#var#definez3Op(var)static_cast(&z3::operator##v

c++ - 在 clang 中循环展开

我正在尝试有选择地展开以下程序中的第二个循环:#includeintmain(){intin[1000],out[1000];inti,j;#pragmanounrollfor(i=100;i当我使用以下选项运行clang(3.5)时,它会展开两个循环4次。clang-std=c++11-O3-fno-slp-vectorize-fno-vectorize-mllvm-unroll-count=4-mllvm-debug-pass=Arguments-emit-llvm-c*.cpp我做错了什么?此外,如果我添加-fno-unroll-loops,或跳过-unroll-count=4标

c++ - 构建 Clang 时未知包 libcxx 和 libcxxabi?

我正在尝试使用来自源代码的libc++构建Clang。我试图在树外将libc++与其他组件构建在一起。我使用的食谱如下。如果我只是将libcxx和libcxxabi放在树中,那么配置不会将它们拾取,而且它们不是自动构建的。我根据LLVM'slibc++StandardLibrary将它们放在llvm/projects中.此外,将makecxx添加到配方中并不像LLVM'slibc++StandardLibrary上宣传的那样有效页。结果是:llvm[0]:ConstructingLLVMBuildprojectinformation.make:***Noruletomaketarget

c++ - 在 Visual Studio 中调用 std::swap 时的 std::bad_function_call

我正在尝试将我的代码从Linux移植到Windows。但是,对于VisualStudio,我的代码因以下错误而崩溃:MicrosoftC++exception:std::bad_function_callatmemorylocation这是我的代码:#includeclassFoo{public:Foo(int):m_deleter{[](){}}{}Foo(constFoo&)=delete;Foo(Foo&&)=default;Foo&operator=(constFoo&)=delete;Foo&operator=(Foo&&)=default;~Foo(){m_deleter(

c++ - 架构 x86_64 的 undefined symbol : OS X, Boost Log,CMake

链接的另一个问题OSX10.9.5x64跨平台项目正在使用CMake工具链构建。使用boost。将所有可执行文件与BoostLog链接时出错(肯定找到了BOOST_PATH,单元测试与Boost测试链接成功)首先尝试。使用Clanggcc-vAppleLLVMversion6.0(clang-600.0.56)(basedonLLVM3.5svn)Target:x86_64-apple-darwin13.4.0Threadmodel:posix建筑boost./bootstrap&&./b2threading=multilink=staticruntime-link=staticins

c++ - 我在这里做错了什么?或者这是一个 clang++ 错误?

以下代码无法在我的Mac上编译#include#includetemplateusingVector=std::array;templateTdot(constVector&l,constVector&r){Tresult{0};for(autoi=0;i;intmain(intargc,constchar*argv[]){Vector3fu{1.0f,2.0f,3.0f};Vector3fv{6.0f,5.0f,4.0f};std::cout这是我从终端编译的方式:clang++-std=c++11-stdlib=libc++repro.cpp-orepro这是我得到的错误:repr

c++ - LLVM-如何通过函数的真实/原始名称获取函数

最近使用llvm在LLVM-IR中插入call指令。问题是,如果我有一个名为add的函数,我无法使用getFuntion(string)找到它,因为IR中的add()可能是_Z3addv_。我知道IR中的所有函数都有一个新名称,但我不知道新名称到底是什么。Module*m=f->getParent();IRBuilderbuilder(m->getContext());Function*call=m->getFunction("add");//callisNULL.std::vectorargs;......Module*m=f->getParent();IRBuilderbuilde

c++ - 如何在 Clang 中获取 NamedDecl 的错位名称?

我正在使用Clang来解析一些C++代码。我想打印我遇到的每个FunctionDecl的名称和损坏的名称。通过将其添加到我的RecursiveASTVisitor,我可以很容易地打印函数名称:boolVisitFunctionDecl(FunctionDecl*f){autodeclName=f->getNameInfo().getName();autofunctionName=declName.getAsString();std::cout我怎样才能打印错位的名字?我按照Sebastian的指示生成的工作代码:constautogetMangledName=[&](FunctionD

c++ - 模板定义找不到我的函数

我正在尝试将一些为MSVC编写的代码移植到Clang上进行编译。但是,查找某些模板函数似乎有问题。这是给我带来问题的结构定义的一部分:templatestructFixedVector{T*ptr;size_tcount;typedefTvalue_type;FixedVector():ptr(0),count(0){}~FixedVector(){DeleteArr(ptr);//Errormessageappearsherecount=0;}//...}DeleteArr(ptr)函数引用了后面定义的函数,如下所示:templateinlinevoidDeleteArr(T*&pt

c++ - 这样的初始化列表在 C++11 中合法吗?

我阅读了C++入门第5版,其中介绍了最新的标准支持列表初始化程序。我的测试代码是这样的:#include#include#include#includeusingstd::cin;usingstd::cout;usingstd::endl;usingstd::string;usingstd::vector;usingstd::ispunct;intmain(intargc,char*argv[]){vectora1={0,1,2};vectora2{0,1,2};//shouldbeequaltoa1return0;}然后我使用Clang4.0:bash-3.2$c++--versio