clang

Conversion to `const Y` not applicable for `R&&` on clang

大城市里の小女人 提交于 2020-01-14 09:43:10
问题 The following code compiles fine with g++ (GCC) 4.7.1 20120721 , but fails with a recently build clang version 3.2 (trunk) . struct Y {}; struct X { operator const Y() const { return Y(); } }; void f(Y&& y) {} int main() { f(X()); return 0; } Changing the conversion operator to operator Y() const is sufficient to make the code compile on both compilers. Which compiler is actually standard compliant in this case? What does the standard actually say about this? The verbatim error as requested:

std::async in clang 3.0 + libc++ doesn't work?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-14 08:59:29
问题 I just compiled and installed clang+llvm 3.0 on my ubuntu 10.04, and also libc++ from svn. As the status in libc++ shows thread support is complete, I wanted to try std::async. So I follow the example given by Anthony Williams in http://www.justsoftwaresolutions.co.uk/threading/multithreading-in-c++0x-part-8-futures-and-promises.html And just make minor change to make it compile: #include <future> #include <iostream> int calculate_the_answer_to_LtUaE() { return 42; } void do_stuff() { std:

Is it possible to initialise an array of non-POD with operator new and initialiser syntax?

痴心易碎 提交于 2020-01-14 08:54:08
问题 I have just read and understood Is it possible to initialise an array in C++ 11 by using new operator, but it does not quite solve my problem. This code gives me a compile error in Clang: struct A { A(int first, int second) {} }; void myFunc() { new A[1] {{1, 2}}; } I expected {{1, 2}} to initialise the array with a single element, in turn initialised with the constructor args {1, 2}, but I get this error: error: no matching constructor for initialization of 'A' new A[1] {{1, 2}}; ^ note:

GCC,LLVM,Clang编译器对比

被刻印的时光 ゝ 提交于 2020-01-14 08:03:09
本文转载自 https://www.cnblogs.com/qoakzmxncb/archive/2013/04/18/3029105.html 在XCode中,我们经常会看到这些编译选项(如下图),有些人可能会有些茫然,本文将对GCC4.2、LLVM GCC 4.2、LLVM compliler 2.0三个编译选项进行一个详细的介绍。 GCC GCC(GNU Compiler Collection,GNU 编译器 套装),是一套由 GNU 开发的编程语言编译器。它是一套以 GPL 及 LGPL 许可证所发行的自由软件,也是 GNU计划的关键部分,亦是自由的类Unix及苹果电脑 Mac OS X 操作系统 的标准编译器。 GCC 原名为 GNU C 语言编译器,因为它原本只能处理 C语言。GCC 很快地扩展,变得可处理 C++。之后也变得可处理 Fortran、Pascal、 Objective-C 、Java, 以及 Ada与其他语言。 LLVM LLVM 是 Low Level Virtual Machine 的简称,这个库提供了与编译器相关的支持,能够进行程序语言的编译期优化、链接优化、在线编译优化、代码生成。简而言之,可以作为多种语言编译器的后台来使用。如果这样还比较抽象的话,介绍下 Clang 就知道了:Clang 是一个 C++ 编写、基于 LLVM、发布于 LLVM

C preprocessor __TIMESTAMP__ in ISO 8601:2004

大兔子大兔子 提交于 2020-01-14 07:12:28
问题 How can I have a __TIMESTAMP__ replacement in ISO 8601:2004? __TIMESTAMP__ Sat Jul 6 02:50:06 2013 vs __TIMESTAMP_ISO__ 2013-07-06T00:50:06Z 回答1: Oh ye optimist! You wouldn't really expect one standard to pay attention to another, would you? The __TIMESTAMP__ define is not in standard C, just so as you are aware. It would be great to have a format like your proposed __TIMESTAMP_ISO__ (would you always want Zulu time, or would it be better to have the local time zone offset?), but frankly, the

How to handle unused warnings caused by empty template parameter pack expansions?

若如初见. 提交于 2020-01-14 07:03:14
问题 An issue I keep facing is one where the compiler complains about an unused variable, even though the variable is used, but it's only used inside a parameter pack expansion that happens to be empty for a specific instantiation. For example: template <std::size_t... I> auto func1(std::index_sequence<I...>) { auto var = get_tuple(); return func2(std::get<I>(var)...); } auto a = func1(std::make_index_sequence<0>()); See live example (try changing the tuple at line 4, by adding an int inside <> to

Linux Clang and Objective-C base library

会有一股神秘感。 提交于 2020-01-14 01:45:29
问题 I have been experimenting with Objective-C using GCC + GNUstep on an Ubuntu system. Now regarding the LLVM Clang compiler, what kind of *step library does it offer? Does it use the GNUstep on the Apple Cocoa? I am mostly interested in the base library - collections, streams, etc. The website doesn't give much information. 回答1: LLVM Clang is a compiler. It is completely independent from the Cocoa / Cocoa Touch frameworks on OS X / iOS, or any other frameworks or platform, for that matter. 回答2:

Clang: How to get the macro name used for size of a constant size array declaration

邮差的信 提交于 2020-01-14 01:38:32
问题 TL;DR; How to get the macro name used for size of a constant size array declaration, from a callExpr -> arg_0 -> DeclRefExpr. Detailed Problem statement: Recently I started working on a challenge which requires source to source transformation tool for modifying specific function calls with an additional argument. Reasearching about the ways i can acheive introduced me to this amazing toolset Clang. I've been learning how to use different tools provided in libtooling to acheive my goal. But

Deterministic builds with clang and lld

老子叫甜甜 提交于 2020-01-13 13:18:38
Deterministic builds with clang and lld Deterministic builds can lower continuous integration costs and give you more confidence in your build and test process. This post outlines what it means for a build to be deterministic, the advantages of deterministic builds, and how to achieve them using LLVM tools. What is a deterministic build, and its advantages A build is called deterministic or reproducible if running it twice produces exactly the same build outputs. There are several degrees of build determinism that are increasingly useful but increasingly difficult to achieve: Basic determinism

How to optimize a native code with android-ndk (Speed Optimization)

拈花ヽ惹草 提交于 2020-01-13 09:28:14
问题 I'm compiling a native code using cygwin and Windows7. I got many optimization tips on Internet. APP_OPTIM := release ndk-build NDK_DEBUG=0 -DNDEBUG LOCAL_CFLAGS += -O2 But I can't understand exactly how to set these on Application.mk and Android.mk. I tried many cases by applying the above tips. but, I don't think that the optimization is applied in my native code. Application.mk APP_PROJECT_PATH := $(shell pwd) APP_MODULES := native_lib APP_OPTIM := release APP_BUILD_SCRIPT := Android.mk