草庐IT

clang_complete

全部标签

c++ - 使用 c++1z 在 <functional> 上出现 clang 4 构建错误

我刚刚将我的archlinux系统更新到最新版本,其中包括gcc7.1.1。尝试构建这个:#includeintmain(intargc,char**argv){return1;}使用命令clang++main.cpp-std=c++1z导致错误:Infileincludedfrommain.cpp:1:Infileincludedfrom/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/functional:60:Infileincludedfrom/usr/bin/../lib

将免费函数用作lpovelapped_completion_routine

我无法理解以下编译错误:unsignedcharbuf[1000];constDWORDmaxBytes=1000;OVERLAPPEDo;voidfoo(DWORDdwErrorCode,DWORDdwNumberOfBytesTransfered,LPOVERLAPPEDlpOverlapped){return;}voidbar(HANDLEhFile){autolambda_foo=[](DWORDdwErrorCode,DWORDdwNumberOfBytesTransfered,LPOVERLAPPEDlpOverlapped){return;};ReadFileEx(hFile,b

c++ - `constexpr` 变量 "used in its own initializer": Clang vs. GCC

这个问题似乎与anexistingone有关,但我不明白theanswerthere中提供的“可移植解决方法”(涉及constautothis_=this;)而且我认为下面的例子更容易理解。我正在使用以下C++17代码片段(livedemo):#includestructTest{constchar*name_{nullptr};constTest*src_{nullptr};constexprTest(constchar*name)noexcept:name_{name}{}constexprTest(constTest&src)noexcept:src_{&src}{name_=s

c++ - 执行限定名称查找时 Clang 和 GCC 之间的不同行为

考虑以下程序:#includenamespaceN{intj=1;}namespaceM{typedefintN;voidf(){std::cout用clang编译它会出现以下编译器错误:prog.cc:10:22:error:'N'(aka'int')isnotaclass,namespace,orenumerationstd::coutGCC不会给出任何编译器错误。我想弄清楚我应该为哪个编译器提交错误报告。哪个编译器具有正确的行为以及原因(对c++标准的引用)?Wandbox-Clang:http://melpon.org/wandbox/permlink/s0hKOxCFPgq5

c++ - clang 的 `-Ofast` 选项在实际中有什么作用,特别是对于与 gcc 的任何差异?

类似于的SO问题Whatdoesgcc'sffast-mathactuallydo?并且与Clangoptimizationlevels的SO问题相关,我想知道什么clang的-Ofast优化在实际方面的作用,这些是否与gcc完全不同,或者这是否比编译器更依赖于硬件。根据clang优化级别的公认答案,-Ofast添加到-O3优化:-fno-signed-zeros-freciprocal-math-ffp-contract=fast-menable-unsafe-fp-math-menable-no-nans-menable-no-infs.这似乎完全与float学相关。但是这些优化对

c++ - gcc 与 clang : inlining a function with -fPIC

考虑这段代码://foo.cxxintlast;intnext(){return++last;}intindex(intscale){returnnext()使用gcc7.2编译时:$g++-std=c++11-O3-fPIC这发出:next():movqlast@GOTPCREL(%rip),%rdxmovl(%rdx),%eaxaddl$1,%eaxmovl%eax,(%rdx)retindex(int):pushq%rbxmovl%edi,%ebxcallnext()@PLT##next()notinlined,callthroughPLTmovl%ebx,%ecxsall%cl

c++ - 使用 stdlibc++ 4.7 启用 C++11 时,出现 clang 错误,而 gcc 编译正常

我一直在努力让C++11工作,在浏览了不同的网站和Q/A之后,我仍然遇到了问题。我想将clang与libstdc++一起使用。在clang状态中表明它受补丁支持-http://clang.llvm.org/libstdc++4.7-clang11.patch.我从macports下载gcc4.7并在gcc4.7的header中进行了相应的更改我不使用libc++的原因是因为libc++和libstdc++之间的ABI兼容性,此线程表明:Whycan'tclangwithlibc++inc++0xmodelinkthisboost::program_optionsexample?好的,一

c++ - 共享内存中的 boost::lockfree::queue 出现问题(boost 1.53、gcc 4.7.2/clang 3.0-6ubuntu3)

我在放置boost::lockfree::queue,..>时遇到问题在共享内存中。我需要它,因为我必须能够将超过65535条消息插入队列,而fixed_sized队列限制为65535。以下代码工作正常(但capacity选项暗示fixed_sized):typedefboost::interprocess::allocatorShmemAllocator;typedefboost::lockfree::queue,boost::lockfree::allocator>Queue;m_segment=newboost::interprocess::managed_shared_memo

c++ - 使用 Clang AST 打印函数的参数

我想获取传递给函数的参数。例如,如果我接到电话printf("%d%d",i,j);输出应该是%d%dij我能够在RecursiveASTVisitor中使用VisitCallExpr()进行函数调用。还能够获取参数的数量和参数类型。但我不知道如何获取参数。boolMyRecursiveASTVisitor::VisitCallExpr(clang::CallExpr*E){for(inti=0,j=E->getNumArgs();igetArg(i)->getType().getAsString()输出:argType:char*argType:intargType:int请帮我获取

c++ - 什么预定义宏可用于检测带有 clang 的调试版本?

MSVC在Debug模式下定义_DEBUG,gcc在Release模式下定义NDEBUG。我可以在clang中使用什么宏来检测代码是否正在为发布或调试编译? 最佳答案 如果您查看IDE的项目设置,您会发现那些宏实际上是在那里手动定义的,它们不是由编译器自动定义的。事实上,编译器无法真正知道它是在构建“调试”还是“发布”,它只是根据用户(或IDE)提供给它的标志进行构建。您必须制作自己的宏并手动定义它们,就像IDE在创建项目时为您所做的那样。 关于c++-什么预定义宏可用于检测带有clan