Questions tagged [clang]

For questions about the clang LLVM compiler front end. For general questions about C, use the C tag.

Usage

This tag should be used for questions specific to clang, an LLVM compiler front end for C-based languages. It should not be used for general questions about C; for those, use the tag.

About

Clang is the LLVM compiler front end for C/C++/Objective-C, which provides fast compiles, useful error and warning messages, an accommodating license and offers an extensible platform for building source level tools.

Why Clang?

The development of a new front-end was started out of a need -- a need for a compiler that allows better diagnostics, better integration with IDEs, a license that is compatible with commercial products, and a nimble compiler that is easy to develop and maintain. All of these were motivations for starting work on a new front-end that could meet these needs.

Current Status

Clang is still under development. Clang is considered to be a production quality C, Objective-C, C++ and Objective-C++ compiler when targeting X86-32, X86-64, and ARM (other targets may have caveats, but are usually easy to fix).

C++ Standards Support

  • C++11 is fully supported in Clang 3.3 and later
  • C++14 is fully supported in Clang 3.4 and later
  • C++17 proposed features are mostly supported in Clang 3.5 and later

Please see the C++ status page for more information.

Related Tags

10121 questions
7
votes
4 answers

Objective-C generics not working for methods? (Xcode 7 Beta (build: 7A120f))

So, obviously, after WWDC I'm playing with new stuff presented during last week. As you know Apple introduced generics to the world of Objective-C Note: This answer is somehow follow-up to this question: Are there strongly-typed collections in…
lvp
  • 2,078
  • 18
  • 24
7
votes
3 answers

Add zero arguments function to _Generic macro

I am trying to generate overloaded functions using _Generic macro in C11, and I have stopped on zero arguments function support, e.g: #define msg(_1) _Generic((_1), char*: msg_string, default: msg_none)(_1) char* msg_none(void){ return…
mucka
  • 1,286
  • 3
  • 20
  • 36
7
votes
2 answers

Excluding internal headers from framework umbrella header

While trying to begin using Swift in a framework (including turning on module support), I started getting messages like this: [snip]/:1:1: Umbrella header for module 'PressKit' does not include header 'NPKBaseAppearance.h' The…
Becca Royal-Gordon
  • 17,541
  • 7
  • 56
  • 91
7
votes
1 answer

clang 3.6 fold expression left/right

I'm trying the fold expression with clang 3.6 '--std=c++1z', but something I don't quite get. The function that I'm testing is: auto minus = [](auto... args) { return (args - ...); }; ... std::cout << minus(10, 3, 2) << std::endl; according to…
Ralph Zhang
  • 5,015
  • 5
  • 30
  • 40
7
votes
1 answer

Is there a gcc option to print the target triplet when cross-compiling?

gcc -dumpmachine is almost perfect, but it doesn't respect flags that affect the target. On the other hand, clang does: $ gcc -dumpmachine x86_64-unknown-linux-gnu $ gcc -dumpmachine -m32 x86_64-unknown-linux-gnu $ clang…
Tavian Barnes
  • 12,477
  • 4
  • 45
  • 118
7
votes
1 answer

C++ redefinition of variable, global namespace polluted and I don't know why

so I think I've done something really stupid and I just can't figure this out. The following program is causing me a lot of pain: #include int time = 0; int main(int argc, char **argv) { std::cout << "hi" << std::endl; return…
aliak
  • 428
  • 4
  • 12
7
votes
1 answer

Is returning uniform initialized reference valid?

Is this code sample valid? using ref = char&; ref foo(ref x) { return ref{x}; } int main() { char a; foo(a); return 0; } seems that: clang 3.5 says YES gcc 4.9 says NO main.cpp: In function 'char& foo(ref)': main.cpp:4:15: error: invalid…
Karol Wozniak
  • 283
  • 1
  • 7
7
votes
1 answer

std::rbegin and std::rend function in GCC 4.9 and clang 3.5

I have been using std::rbegin and std::rend in MSVC 2013. When I tried to compile my code using GCC 4.9.1 or clang 3.5.0, both tell me that 'rbegin' and 'rend' are not part of namespace 'std'. See the code example below. Am I doing something wrong…
Peter K
  • 1,372
  • 8
  • 24
7
votes
1 answer

Understand assembly code in c

I'm reading some C code embedded with a few assembly code. I understand that __asm__ is a statement to run assembly code, but what does __asm__ do in the following code? According to the output (i.e., r = 16), it seems that __asm__ does not effect…
ZLW
  • 151
  • 9
7
votes
1 answer

Who is failing, boost, clang, or gcc? Issue with std::chrono used with boost::asio

As noted by this question, boost::asio now can use the C++11 chrono objects if they are available. However, the following code compiles with but not with clang 3.6.0-svn223366-1~exp1 #include #include #include…
ilektron
  • 390
  • 3
  • 15
7
votes
2 answers

Loop unrolling in clang

I am trying to selectively unroll the second loop in the following program: #include int main() { int in[1000], out[1000]; int i,j; #pragma nounroll for (i = 100; i < 1000; i++) { in[i]+= 10; } …
k01
  • 71
  • 1
  • 1
  • 3
7
votes
1 answer

How to use .pch with clang?

I'm having header file header.h: #define TEST_VALUE 1 #define TEST_STRING "hello world" and source file source.cpp: #include "header.h" #include "stdio.h" int main() { printf(TEST_STRING"\n"); } I've followed clang pch article and…
4ntoine
  • 19,816
  • 21
  • 96
  • 220
7
votes
1 answer

Python clang does not search system include paths

When using libclang from Python, it doesn't seem to automatically search the system's include paths. Is there a reliable way to get these paths? I don't like hardcoding paths as I'm writing code that will run on a variety of UNIX systems. For…
csl
  • 10,937
  • 5
  • 57
  • 89
7
votes
1 answer

What is my version of LLVM & clang (OSX)?

On Mac OS, if I run clang --version, I get: Apple LLVM version 6.0 (clang-600.0.34.4) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.0.0 Thread model: posix Since LLVM official page suggests that the current LLVM version is 3.5, it seems that…
Maxim Chetrusca
  • 3,262
  • 1
  • 32
  • 28
7
votes
1 answer

Should the visibility attribute be specified in declarations or in definitions?

In his paper about shared libraries, Ulrich Drepper recommends that symbol visibility is globally set to hidden when building the library, and then, in the source code, set to default for each symbol that is meant to be public to export it. However,…
djsp
  • 2,174
  • 2
  • 19
  • 40