问题标签 [clang++]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
179 浏览

boost - Boost.Wave 1.52 不在 Darwin 上使用 clang++ 构建

我已经应用Compile boost C++11 clang mac 找不到 cstddef 并调用 build 如下 ./b2 variant=debug,release --layout=versioned toolset=clang cxxflags="-fPIC -std=c++11 -stdlib=libc++ -arch i386 -arch x86_64" linkflags="-stdlib=libc++ -arch i386 -arch x86_64" threading=multi link=shared --stagedir=stage_darwin_intel_shared_mt stage

一切都建立起来了,除了警告日志和 Boost.Wave 失败: http ://pastebin.com/ZHkmTWaq

PS 静态风格的助推器可以很好地构建 Wave。

0 投票
2 回答
346 浏览

c++ - clang++ - 将模板类名视为类范围内的模板

似乎clang ++(我尝试过clang 3.2)将模板类的名称视为实例化类,而不是类范围内任何出现的模板。例如,以下代码

我应该怎么做才能编译它?

0 投票
2 回答
635 浏览

c++ - 为什么 GCD 会增加执行时间?

我尝试学习 Grand Central Dispatch (GCD) 并使用以下代码进行测试:

使用 GCD:

没有 GCD:

GCD的测试结果:

没有 GCD 的测试:

我认为 GCD 应该减少执行时间,但结果却相反。我不确定我是否滥用了 GCD。操作系统环境是 Mac OS X 10.8 和 Xcode 4.5。编译器是 Clang++ 3.1。硬件是带有 i5 CPU 的 Macbook Pro,它有两个内核。

为了比较,我使用 OpenMP(在同一台笔记本电脑上也使用 Xcode 4.5 附带的 GCC):

和 w/wo (-fopenmp),我有两个可执行文件要测试,

编译时带有-fopenmp标志:

编译时没有-fopenmp标志:

使用 OpenMP,可以减少执行时间。

0 投票
1 回答
843 浏览

c++ - 替换失败有时是错误?

以下代码片段尝试实现一个 'std::is_constructible<A, int>':

使用 g++ 可以正常工作;使用 clang++ 会打印以下错误:

版本信息:clang 版本 3.3 (trunk 172418) (llvm/trunk 172417), g++ (Debian 4.7.2-4) 4.7.2。

我的问题: 恕我直言,这应该是 SFINAE。我在这里错过了什么还是clang++有问题?

(我知道有 is_constructible() 但我不允许使用它——这不是我问题的重点。)

0 投票
1 回答
1816 浏览

c++ - libconfig++ -stdlib=libc++ 未定义符号

试图获得一个非常简单的 libconfig++ 工作示例。但是,由于编译器选项“-stdlib=libc++”和“-std=c++11”,我遇到了以下链接错误。

环境

达尔文 iMac.local 12.2.0

达尔文内核版本 12.2.0

xnu-2050.18.24~1/RELEASE_X86_64 x86_64

资源

建造

clang++ -o main main.cpp -lconfig++ -stdlib=libc++ -std=c++11

错误

0 投票
1 回答
805 浏览

c++ - 积分常数和模板参数推导

我想将传递给函数的编译时常量整数捕获为模板类型。未来的目标是推出我自己的(非常有限的)表达式模板,它从非常简单的表达式(编译时间常量 int 和变量的总和)创建表达式,例如:-2*i + 3*k。

我开始很慢,我有以下代码:

2*Foo(3) 的模板参数推导失败。我已经读过函数没有 constexpr 参数之类的东西。

有没有办法完成我想要的?

0 投票
1 回答
2245 浏览

c++ - clang: stripping class names from the output

I build a C++ project of mine using clang++, using the following command line command (split into lines):

However, when I run strings <filename>, several class names show up, despite the -O4 in the command line. I've tried -Wl,-s which should tell llvm to strip all symbols, but that doesn't remove these.

The class names that show up seem to all have one thing in common: they have a vtable. One of these classes is :

It shows up as the symbol :

I don't like it that my namespace and class names show up in the final file. How do I strip these? My binary is a command line utility, so only the main function should be exported.


Even after supplying -fno-rtti (as suggested by @n.m.), some names still remain, such as :

(MyClassInstance being a subclass of the MyClass above)

Additionally, even the names of global variables are in the binary.

0 投票
2 回答
1148 浏览

c++ - 按值传递期间的隐式转换有效,但按引用传递无效

使用 clang++ 4.1 编译:

印刷,

而如果我定义f如下,

我得到一个编译错误,

为什么?我不明白为什么做f参考会导致问题。

0 投票
2 回答
4681 浏览

clang++ - QtCreator下的clang++不能用c++11

操作系统:OS X 10.8.1 QtCreator:2.6.2

命令行很好,但 QtCreator 无法编译代码。

命令行 :

QtCreator 的编译器设置 http://www.flickr.com/photos/92283971@N04/8453188038/in/photostream

Qt .pro 文件

错误信息:

clang:错误:-stdlib=libc++ 的无效部署目标(需要 OS X 10.7 或更高版本) make: *** [main.o] 错误 1

但我的操作系统号是 10.8.1

0 投票
1 回答
1016 浏览

qt - Qt Creator 无法构建调试器助手

我在 Qt 论坛上问过这个问题,但这些天他们似乎很安静。

我正在运行相对较新的 Qt Creator 2.6.2(带有 Qt 5.0.1)。当我尝试构建调试器助手时,我收到以下错误:

使用工具链“GCC(x86 64 位)”构建帮助程序...在 /Developer/Applications/Qt/5.0.1/clang_64//qtc-debugging-helper/ 中构建帮助程序“GDB 助手”

运行 /Developer/Applications/Qt/5.0.1/clang_64/bin/qmake -spec macx-clang dumper.pro -nocache CONFIG+=x86_64 ...

运行 /usr/bin/make all -k ... 在 /Developer/Applications/Qt/5.0.1/clang_64//qtc-debugging-helper/ 中运行“/usr/bin/make all -k”时出错:进程返回退出代码 2:clang++ -c -pipe -mmacosx-version-min=10.6 -O2 -Wall -W -fPIC -DUSE_QT_CORE=1 -DUSE_QT_GUI=1 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../mkspecs/macx -clang -I。-I../include -I../include/QtWidgets -I../lib/QtWidgets.framework/Versions/5/Headers -I../include/QtGui -I../lib/QtGui.framework/Versions /5/Headers -I../include/QtCore -I../lib/QtCore.framework/Versions/5/Headers -I. -I/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/System/Library/Frameworks/AGL.framework/Headers -o dumper.o dumper.cpp make: clang++: No such file or directory make : * [dumper.o] 错误 1 ​​制作:由于错误,目标“全部”未重新制作。构建失败。

所以,我看到它正在寻找一个我显然没有的名为“clang++”的文件。有人可以向我解释一下解决方法是什么吗?我习惯于只使用 Qt 的预构建安装包。

谢谢。