草庐IT

clang-omp

全部标签

c++ - CMake、VTK8 和 Embarcaderos Clang 编译器

C++Builder(10.2.3)的当前Embarcadero版本附带Clang32和64位C/C++编译器。Clang版本号称是3.3,(http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Win32_Clang-enhanced_Compilers)。我正在研究使用这些编译器和CMake编译VTK8.0和其他库。但是,CMake附带的“系统”CMake文件(Windows-Embarcadero.cmake)并未针对Clang配置,而是针对较旧的bcc32编译器配置。Embarcadero建议将其分发的“Windows-Embarc

c++ - 关于静态全局 lambda 变量的错误 clang-tidy 警告?

提供以下代码,在全局范围内,clang-tidy不给出警告:autotest=[]{};但是,当执行以下操作时,它会:#includeautotest=[]{std::tuplet{1,2,3};};:3:6:warning:initializationof'test'withstaticstoragedurationmaythrowanexceptionthatcannotbecaught[cert-err58-cpp]autotest=[]{^/opt/compiler-explorer/gcc-8.2.0/lib/gcc/x86_64-linux-gnu/8.2.0/../../

c++ - 如何将大对象复制到循环内的 omp 任务中?

我正在使用一个while循环来启动多个omp任务。每个任务都需要复制一个相当大的对象(作为firstprivate)。由于我的设置,大对象(在这个例子中是一个vector)会被简单地复制两次:structbigStruct{boolnext(){/*dosomethingwithm_bigVector*/}std::vectorm_bigVector;/*other(big)datamembers*/};bigStructs;#pragmaompparallel{#pragmaompsinglewhile(s.next()){autoobj=s.m_bigVector;//copyth

c++ - 为什么我使用 XCode 的 llvm 与来自 MacPorts 的 clang++ 获得更快的二进制文件?

我已经编写了一个基准测试方法来测试我的C++程序(搜索游戏树),并且我注意到使用XCode4.0.2中的“LLVM编译器2.0”选项进行编译可以使我的二进制文件速度明显快于我使用来自MacPorts的最新版本的clang++进行编译。如果我理解正确的话,我在这两种情况下都使用了clang前端和llvm后端。Apple是否改进了他们的clang/llvm发行版以生成更快的MacOS二进制文件?我找不到有关该项目的太多信息。以下是我的程序为各种编译器生成的基准,全部使用-O3优化(越高越好):(Xcode)"gcc4.2":38.7(Xcode)"llvmgcc4.2":51.2(Xcod

c++ - clang 3.3/Xcode & libc++:std::getline 在调用 ifstream::clear() 后不读取数据

以下程序演示了libc++和libstdc++(使用clang3.3)之间std::getline行为的不一致。程序打开文件testfile,读取它直到eof,然后使用ifstream::clear清除错误位并尝试再次从同一文件句柄读取以查看是否有新数据附加到文件。#include#include#includeusingnamespacestd;intmain(){ifstream*file=newifstream("testfile");if(!file->is_open()){coutclear();//removeendoffileevilbitsstringline;//wo

c++ - Clang 在模板上下文中找不到函数定义后实例化的函数

我一直在尝试使用SeanParent的“C++Seasoning”演示文稿派生的代码,并将我的问题归结为以下代码:#includestructcontainer{structconcept{virtual~concept(){}virtualvoidfoo_()=0;};templatestructmodel:concept{model(Tx):data_(x){}voidfoo_(){foo(data_);//Line13}Tdata_;};templatecontainer(Tx):self_(newmodel(x)){}//Line20std::unique_ptrself_;f

c++ - 为什么在 Visual Studio 中使用 LLVM+Clang 时未定义 __clang__?

我为Windows安装了LLVM,其中包括Clang和一些其他工具。它与VisualStudio集成,甚至让我在项目属性中选择“平台工具集”。但是,当我选择LLVM附带的任何工具集时,未定义__clang__,而是定义了_MSC_VER。在VisualStudio中使用LLVM和Clang时如何定义__clang__?我的VisualStudio版本是2015预览版(但是我也在2013年进行了测试,但也没有成功),我的LLVM版本基于SVN版本225473。我试过LLVM-vs2012、LLVM-vs2013和LLVM-vs2014作为平台工具集但没有成功。

c++ - 用C++标准库分析Clang线程安全

这描述了如何使用C++中的注释完成静态线程安全分析:http://clang.llvm.org/docs/ThreadSafetyAnalysis.html我如何将其与标准类型(如std::mutex和std::lock_guard)一起使用?mutex.h的示例代码注释了一个自定义接口(interface)。我是否拥有在那里定义的类型“Mutex”并使用带注释的方法使用std::mutex实现一个类,或者Clang是否以某种方式带来带注释的类型? 最佳答案 在最新版本的clang中,您可能不必再包装std::mutex,因为线程安

c++ - 无法使用 Microsoft CodeGen 使用 Visual Studio 2015 和 Clang 3.7 构建 Google Test

使用VS2015及其新的内置clang工具集/项目模板,我无法成功构建GoogleTest。我收到以下错误:Erroruseofundeclaredidentifier'chdir';didyoumean'_chdir'?Erroruseofundeclaredidentifier'fdopen'Erroruseofundeclaredidentifier'read'Erroruseofundeclaredidentifier'write'Erroruseofundeclaredidentifier'close'Erroruseofundeclaredidentifier'O_RDON

c++ - 为什么链接到 librt 在 g++ 和 clang 之间交换性能?

我刚找到thisanswer来自@tony-d,带有用于测试虚函数调用开销的工作台代码。我检查了是否使用g++进行基准测试:$g++-O2-ovdtvdt.cpp-lrt$./vdtvirtualdispatch:1500000000.128562switched:1500000000.0803207overheads:1500000000.0543323...我得到了比他更好的性能(比率大约为2),但后来我用clang进行了检查:$clang++-3.7-O2-ovdtvdt.cpp-lrt$./vdtvirtualdispatch:1500000000.462368switched