草庐IT

clang_complete

全部标签

c++ - 使用 Google Test、Clang 和 libc++ 构建测试时遇到问题

我尝试使用以下CMake配置构建GoogleTest:$CMAKE_CXX_COMPILER="clang++"CMAKE_CXX_FLAGS="-std=c++11-stdlib=libc++-U__STRICT_ANSI__"cmake../sourceBuilding显示CMake选择了正确的编译器,但我的编译器标志没有通过:$VERBOSE=1make.../Users/jfreeman/local/bin/clang++-I/Users/jfreeman/work/googletest/source/include-I/Users/jfreeman/work/googlete

c++ - 如何从 std::basic_ios 为 OS X 上的 clang 获取文件描述符?

我正在将一些代码移植到DarwinOSX,作为更改的一部分,我们从gcc转到clang编译器。代码中有一个2005年的函数,在网上多处贴过。它为几个不同的旧版本GCC提供了功能,我已经编辑了除最后一个版本之外的所有功能,v3.4.0或更高版本。该代码取决于两个GCC特定类:__gnu_cxx::stdio_filebuf和__gnu_cxx::stdio_sync_filebuf。//!Similartofileno(3),buttakingaC++streamasargumentinsteadofa//!FILE*.Notethatthereisnowayforthelibraryt

c++ - 候选模板被忽略 : substitution failure(error with clang but not g++)

我有一个替换失败的问题,一些类似问题的答案对我没有帮助。代码如下:templateclassReference{public://...templateusingmatrix_t=int[r][c];Reference(constmatrix_t&mat){}};templateclassPartition{//...public://...templateusingmatrix=int[r][c];templatevoidreadPattern(constmatrix&pattern){//...}//...};我这样调用这个模板函数:intmain(){//...constintD

c++ - gcc 与 clang、msvc 和 icc : Is this function call ambiguous?

我能得到的所有编译器都同意这很好:templateautofoo(Check,T...)->void;templateautofoo(int,T...)->void;intmain(){foo(7,"");}但是,根据gcc,以下代码(带有不能从函数参数推导的前导模板参数)是不明确的:templateautobar(Check,T...)->void;templateautobar(int,T...)->void;intmain(){bar(7,"");//ambiguousaccordingtogccbar(7);//justfine}另一方面,clang、msvc和icc对此非常满

c++ - 缩小从 `int`(常量表达式)到 `unsigned int` 的转换 - MSVC vs gcc vs clang

constexprinti=100;structF{F(unsignedint){}};intmain(){F{i};}上面的代码片段:使用-Wall-Wextra-Wpedantic在g++7上编译没有警告。使用-Wall-Wextra-Wpedantic在clang++4上编译没有警告。无法在MSVC2017上编译:conversionfrom'constint'to'unsignedint'requiresanarrowingconversion问:这里MSVC是不是错了?liveexampleongodbolt.orginti=100;structF{F(unsignedint

c++ - 如何告诉 clang 将调试符号放入可执行二进制文件中?

这个问题在这里已经有了答案:Whydoesa2-stagecommand-linebuildwithclangnotgenerateadSYMdirectory?(1个回答)关闭5年前。我的编译命令在macOSSierra中是clang-std=c11-g-Wall-Werror-fsanitize=address-file.c-ofile编译后,它还会生成一个额外的file.dSYM文件,其中包含所有调试符号。但是,当我使用WSL或其他*nix系统时,它不会生成这样的文件,调试符号被嵌入到可执行二进制文件中。所以我只是想知道有没有办法在macOS中使用clang做同样的事情。

c++ - g++ 和 clang++ 与在模板类中定义的友元模板函数的不同行为

另一个类型的问题“g++和clang++之间谁是正确的?”适用于C++标准专家。下面的代码templatestructfoo{templatefriendvoidbar(){}};intmain(){foof0;foof1;}使用clang++编译没有问题(只有两个“未使用的变量”警告)但给出以下错误tmp_002-11,14,gcc,clang.cpp:Ininstantiationof‘structfoo’:tmp_002-11,14,gcc,clang.cpp:27:12:requiredfromheretmp_002-11,14,gcc,clang.cpp:20:16:erro

c++ - Clang 修改析构函数中的返回值?

在尝试编写一个类来计时调用它的构造函数和析构函数之间的持续时间时,我遇到了我认为是clang中的错误。(编辑:这不是错误;它是实现定义的复制省略)下面的timer结构保留指向作为引用传入的持续时间对象的指针,并将范围的持续时间添加到此。#include#includestructtimer{usingclock=std::chrono::high_resolution_clock;usingtime_point=clock::time_point;usingduration=clock::duration;duration*d_;time_pointstart_;timer(durat

c++ - CMake 和 Clang 工具链接错误(树外)

我正在尝试编译RecursiveASTVisitorexampleofClang使用CMake文件。构建项目进行得很顺利,但是,由于对LLVM和Clang库的多个undefinedreference,链接C++可执行文件失败。我正在LLVM/Clang源文件树之外构建示例。这是我的CMakeLists.txt(我正在使用FindClang.cmakeandFindLLVM.cmakefromthisproject):cmake_minimum_required(VERSION2.8.4)project(ifcount)set(CMAKE_MODULE_PATH${CMAKE_CURRE

c++ - VS2015 和 clang 编译此代码,但 g++ 拒绝它。哪一个是正确的?

VS2015和clang编译这段代码,但是g++rejectsit.namespaceA{structB{friendvoidf();};}voidA::f(){}intmain(){}我认为g++是正确的,因为7.3.1.2/3中的注释:Ifafrienddeclarationinanon-localclassfirstdeclaresaclass,function,classtemplateorfunctiontemplate97thefriendisamemberoftheinnermostenclosingnamespace.Thefrienddeclarationdoesno