草庐IT

clang-omp

全部标签

c++ - 启用 openmp 时出错 - "ld: library not found for -lgomp"和 Clang 错误

我正在尝试让openmp在Mavericks上的程序中运行,但是当我尝试使用标志-fopenmp进行编译时,我收到以下错误:ld:librarynotfoundfor-lgompclang:error:linkercommandfailedwithexitcode1(use-vtoseeinvocation)我正在运行的命令是:gccmyProgram.cpp-fopenmp-omyProgram另外,当我运行gcc时,我会收到Clang警告,我觉得这很奇怪。并且查看/usr/bin/gcc它似乎没有链接到Clang。关于如何修复我的Clang错误并让openmp编译的任何建议?

c++ - 为什么这段代码用 gcc 编译而不用 clang

此代码与gcc/g++和msvc完美结合,但不适用于clang。一直报找不到Log的匹配函数,这是怎么回事?#includetemplateautoCall(Functionfunc,Args&&...args)->typenamestd::result_of::type{returnfunc(std::forward(args)...);}templateT(*Log(T(*FuncPtr)(Args...)))(Args...){returnFuncPtr;}intmain(){autor=Log(Call)([](intx){returnx*10;},10);std::cerr错

c++ - 转换在 Visual Studio 2015 中不明确,但在 clang 中没有

以下代码是googlemock项目中代码的简化版本,无法在VisualStudio2015Update1中编译,但可以在clang[AppleLLVM版本7.0.0(clang-700.1.76)]上编译。structConvertibleFromAny{ConvertibleFromAny(inta_value);templateConvertibleFromAny(constT&a_value);};templatestructMatcher{Matcher(Tvalue);};templatestructEqMatcher{explicitEqMatcher(constRhs&r

c++ - 为什么对于这个涉及求幂的简单函数,clang 生成的代码比 gcc 快得多?

以下使用clang编译的代码比使用相同编译器标志(-O2或-O3):#include#include#include#includelongdoublefunc(intnum){longdoublei=0;longdoublek=0.7;for(intt=1;tstart,end;start=std::chrono::system_clock::now();autoi=func(num);end=std::chrono::system_clock::now();std::chrono::durationelapsed=end-start;std::cout.precision(std:

c++ - 如何在 Clang 中使用 C++ 模块?

模块是#includes的替代品。ClanghasacompleteimplementationforC++.如果我现在想通过Clang使用模块,我该怎么做?使用importstd.io;在C++源文件中还不能工作(编译),因为模块规范(包括语法)不是最终的。Clangdocumentation指出,当通过-fmodules标志,#includes将被重写为适当的导入。但是,检查预处理器会提示其他情况(test.cpp仅包含#include和一个空的main):$clang++-3.5-fmodules-Etest.cpp-otest$grep"printf"testexternint

c++ - g++/Clang 中的另一个错误? [C++ 模板很有趣]

查看以下代码(仅供娱乐)namespaceN{templatestructK{};}templatestructX{typenameT::templateK*p;//shouldgiveerror//N::Khasnotemplatemembernamed`K`};intmain(){X>l;}代码在g++(4.5.1)和Clang上编译,而Comeau和IntelC++给出(类似)错误。我在Comeau上遇到的错误是:"ComeauTest.c",line13:error:class"N::K"hasnomember"K"typenameT::templateK*p;^detecte

c++ - clang:没有外线的虚拟方法定义(纯抽象 C++ 类)

我正在尝试使用Clang-3.5编译以下简单的C++代码:test.h:classA{public:A();virtual~A()=0;};test.cc:#include"test.h"A::A(){;}A::~A(){;}我用来编译这个的命令(Linux,uname-r:3.16.0-4-amd64):$clang-3.5-Weverything-std=c++11-ctest.cc我得到的错误:./test.h:1:7:warning:'A'hasnoout-of-linevirtualmethoddefinitions;itsvtablewillbeemittedinevery

c++ - gcc 和 clang 在运算符重载解析期间隐式实例化模板参数

考虑这段代码:structA;//incompletetypetemplatestructD{Td;};templatestructB{int*p=nullptr;};intmain(){B>u,v;u=v;//doesn'tcompile;complainthatD::dhasincompletetypeu.operator=(v);//compiles}Demo.从u.operator=(v)编译但u=v;不是,在后一个表达式的重载解析期间,编译器必须隐式实例化D-但我不明白为什么需要实例化。为了让事情更有趣,这段代码编译:structA;//incompletetypetempl

c++ - clang-format 可以在列中对齐变量或宏赋值吗?

是否可以在列中使用clang格式对齐变量赋值?例如:intsomeInteger=42;std::stringsomeString="string";constunsignedsomeUnsigned=42;#defineSOME_INTEGER42#defineSOME_STRING_LITERAL"string"#defineSOME_CONSTANT42enumEnum{ONE=1,TWO=2,THREE=3,FOUR=4,FIVE=5,SIX=6,SEVEN=7};比以下更具可读性:intsomeInteger=42;constunsignedsomeUnsigned=42;s

c++ - GCC 和 Clang 模板调用解析差异

给定以下代码:#includestructAlice{templatevoidoperator|(constA&/*a*/)const{std::coutvoidoperator|(constA&/*a*/,constAlice&/*alice*/){std::cout使用GCC4.8.1、4.9和clang3.4编译时不会发出警告,但会给出不同的结果。$g++-Wall-Wextra-std=c++11alice.cpp&&./a.outoperator|non-member$clang++-Wall-Wextra-std=c++11alice.cpp&&./a.outoperato