Tag: 铿锵

是否可以抑制Xcode 4静态分析器警告?

Xcode 4静态分析器在我的代码中报告了一些误报。 有什么办法可以压制他们吗?

在C ++ 1y模式中,Clang> = 3.3不能parsing<cstdio>头文件

我有一个项目,正确地编译和运行在g ++ 4.8.1和铿锵> = 3.3在c + + 11模式。 但是,当我切换到实验-std=c++1y模式时,在通过Boost.Test间接包含的<cstdio>头文件中的clang 3.3(但不是g ++)扼stream圈(所以我不能轻易地自己改变它) // /usr/include/c++/4.8/cstdio #include <stdio.h> // Get rid of those macros defined in <stdio.h> in lieu of real functions. // … #undef gets // … namespace std { // … using ::gets; // <– error with clang++ -std=c++1y // … } 与以下错误消息: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/cstdio:119:11:错误:在全局中没有名为“gets”的成员命名空间 在本教程中 ,如何设置一个现代的C […]

clang的-Wweak-vtables是什么意思?

我基本上不明白铿锵的-Wweak-vtables 。 这是我迄今观察到的: 情况一:(触发警告) class A { public: virtual ~A(){} }; class B : public A { public: virtual ~B(){} }; int main(){} 情况二:(不触发警告) class A { public: virtual ~A(){} }; int main(){} 案例三:(不触发警告) class A { public: virtual ~A(); }; A::~A(){} class B : public A { public: virtual ~B(){} }; int main(){} 情况四:(触发警告) […]

LLVM最大的好处是什么?

有没有人有LLVM , llvm-gcc或Clang的经验 ? llvm背后的整个想法对我来说似乎非常有趣,而且我很感兴趣看到它的performance。 如果这些工具还没有准备好生产,我只是不想把很多时间花在试用这些工具上。 如果你有这些工具的经验,你觉得他们怎么样? 你遇到什么主要的限制? 什么是最大的好处? 非常感谢!

如何在Clang中使用C ++ 11function?

我如何使用Clang中最新的C ++ 11function? 哪些(子)function集支持?

当使用respondsToSelector时,禁止使用“'…'”

我通过在运行时select最新的API来支持10.4+。 if ([fileManager respondsToSelector:@selector(removeItemAtPath:error:)]) [fileManager removeItemAtPath:downloadDir error:NULL]; else [fileManager removeFileAtPath:downloadDir handler:nil]; 在这种情况下,10.5和以上将使用removeItemAtPath:error:和10.4将使用removeFileAtPath:handler: 太好了,但我还是得到了旧方法的编译器警告: warning: 'removeFileAtPath:handler:' is deprecated [-Wdeprecated-declarations] 是否有语法if([… respondsToSelector:@selector(…)]){ … } else { … }提示编译器(Clang)不要在该行发出警告? 如果没有,是否有一种方法来标记该行忽略-Wdeprecated-declarations ? 在看到一些答案之后,让我澄清一点,混淆编译器不知道我在做什么不是一个有效的解决scheme。

为什么铿锵声++只销毁一个foo对象?

我有以下示例代码: #include <iostream> using namespace std; struct foo { foo() { cout << "foo constructed.\n"; } ~foo() { cout << "foo destroyed.\n"; } }; struct bar { bar(foo t=foo{}) { } }; int main(int argc, char **argv) { bar X[2]{}; return 0; } 当我使用clang ++ -std = c ++ 11 test.cc进行编译时,程序产生以下输出: foo constructed. foo constructed. […]

为什么Clang优化这个代码?

代码的目的是find代表0到1之间的值的32位浮点位模式的总数。在我看来,这应该工作,但由于某种原因,从铿的组装输出基本上是return 0; 。 我用Clang 3.3和Clang 3.4.1编译,使用-std=c++1y -Wall -Wextra -pedantic -O2和-std=c++1y -Wall -Wextra -pedantic -O3 铿锵3.4使用-O2和-O3优化了所有的东西。 铿锵3.3只会优化-O3的所有function。 通过“优化一切”我的意思是这是程序的汇编输出: main: # @main xorl %eax, %eax ret #include <limits> #include <cstring> #include <cstdint> template <class TO, class FROM> inline TO punning_cast(const FROM &input) { TO out; std::memcpy(&out, &input, sizeof(TO)); return out; } int main() { uint32_t i = […]

编译一个相当简单的c ++ 11程序时,gcc和clang之间的不同结果

我试图了解在这个简单的C ++ 11程序的输出中由gcc和clang公开的不同行为是否是由于clang(Xcode 5.0.2,OS X 10.8.5)中的一个错误引起的。 代码如下: #include <iostream> int main() { int matrix[][3]{{1,2,3}, {4,5,6}, {7,8,9}}; auto dyn_matrix = new int[3][3]{{1,2,3}, {4,5,6}, {7,8,9}}; std::cout << matrix[0][1] << std::endl; std::cout << dyn_matrix[0][1] << std::endl; return 0; } 如图所示,我试图使用统一的初始化来初始化一个大小为3×3的匿名(名为)multidimensional array。 当用MacPorts编译gcc 4.7时,获得预期的输出: $g++-mp-4.7 -std=c++11 dyn_matrix.cpp -o dyn_matrix $ ./dyn_matrix 2 2 $ 相反,如果使用铛,输出读取: $ clang++ -std=c++11 -stdlib=libc++ […]

如何用clang编译C ++

我已经在Ubuntu下使用apt-get安装了clang ,并且可以使用它成功编译C文件。 但是,我不知道如何通过它来编译C ++。 我需要做什么来编译C ++?