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
1 answer

including static libraries with -all_load flag

In what cases exactly do you need -all_load flag? Lets say I have something like g++ source.cpp -o test libA.a libB.a libC.a From what i recall if there is some reference to a symbol used in source.cpp that is present in say libB.a file then…
JamesWebbTelescopeAlien
  • 3,547
  • 2
  • 30
  • 51
7
votes
1 answer

Why this behavior on clang -O3?

Here is a short program to count the number of divisors of an integer. The program does work correctly. The problem is, however, that under the -O3 optimization flag of the current trunk of the Clang C++ compiler (version 3.3, trunk 180686) the…
oblitum
  • 11,380
  • 6
  • 54
  • 120
7
votes
1 answer

Disabling clang C++11 warnings

I cannot for the life of me get clang to stop warning me about C++11 extensions. Anywhere I use "auto" or any other C++11 extension it spits out a warning. I have the flag -Wno-c++11-extension but it still prints them. Here's my makefile: CXX =…
Lerp
  • 2,957
  • 3
  • 24
  • 43
7
votes
1 answer

expression is not an intergral constant clang libc++ threading

I'm trying to compile a really simple thread program on my linux machine(ubuntu), but clang seems to still throw an error at me even when I specify libc++. my program is: #include #include void call_from_thread() { std::cout…
Syntactic Fructose
  • 18,936
  • 23
  • 91
  • 177
7
votes
2 answers

In Objective-C ARC, what are "BPTRs declared within extern "BCPL" blocks"?

In the Clang documentation for ARC, it says: ARC applies to Objective-C pointer types, block pointer types, and [beginning Apple 8.0, LLVM 3.8] BPTRs declared within extern "BCPL" blocks. What are these "BPTRs declared within extern "BCPL"…
user102008
  • 30,736
  • 10
  • 83
  • 104
7
votes
2 answers

Suppress -Wtautological-compare warning

I have some code like Q_ASSERT(value_which_is_always_smaller_than_4 < 4) where Q_ASSERT is Qts assert macro. Now clang, when seeing this warns me about it, because the comparison is always true. Nice that it can detect this, but that's the point of…
Inkane
  • 1,440
  • 1
  • 15
  • 32
7
votes
1 answer

Remove Boost libstdc++ dependency with clang++/libc++?

The answer to this question How to compile/link Boost with clang++/libc++? states to build Boost with clang++ and libc++, the following should do: ./b2 clean ./b2 toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" I tested the above…
user183394
  • 1,033
  • 1
  • 11
  • 20
7
votes
1 answer

Blocks retain cycle from naming convention?

I am surprised to find the following behavior... @interface Foo : NSObject - (void)addBar:(id)aBar withCompletion:(void(^)(void))completion; @end @interface AwesomeClass : NSObject @property (strong, nonatomic) Foo *foo; -…
edelaney05
  • 6,822
  • 6
  • 41
  • 65
7
votes
2 answers

Objective-C ARC and Legacy Runtime compiling error

I'm trying to compile sources with Xcode 4.6, for 32bit architecture, but getting this error: error: -fobjc-arc is not supported on platforms using the legacy runtime Command…
rdshck
  • 592
  • 1
  • 5
  • 12
7
votes
4 answers

Xcode Clang Bus error 10

When I am trying to build my code on Xcode, I am getting clang: error: unable to execute command: Bus error: 10 clang: error: linker command failed due to signal (use -v to see invocation) Anyone knows why? The code builds fine on my colleague's…
dudeking
  • 764
  • 1
  • 9
  • 12
7
votes
3 answers

clang compiling error (undefined reference to objc_autoreleasepoolpush)

So, I got Ubuntu and clang3.0 installed and a simple program.m: #include int main() { @autoreleasepool{ NSLog(@"Hi"); } return 0; } and I try to compile it like this: clang first.m -I…
Manifestor
  • 575
  • 5
  • 19
7
votes
4 answers

Diff utility that is C++ aware

Is there a free diff utility that can compare two C++ files using their ASTs instead of the text? What I was thinking of is something like: convert both files to AST Render AST back as C++ code (this canonicalizes indentation) Do normal diff…
tohava
  • 5,344
  • 1
  • 25
  • 47
7
votes
1 answer

Unconventional Calls with Inline ASM

I'm working with a proprietary MCU that has a built-in library in metal (mask ROM). The compiler I'm using is clang, which uses GCC-like inline ASM. The issue I'm running into, is calling the library since the library does not have a consistent…
Sam Cristall
  • 4,328
  • 17
  • 29
7
votes
1 answer

CppUnit Linking error with Clang on Mac OS X

I am trying to compile a test program using CppUnit. The problem is, with this sample code: //[...] class EntityComponentTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE( EntityComponentTest ); CPPUNIT_TEST( testGetComponents…
DanB91
  • 1,399
  • 1
  • 13
  • 23
7
votes
1 answer

Non-static member initializer from another non-static

Very simple question. Is this valid C++11? struct Foo { int bar = 1; int baz = bar; }; GCC (4.7.2) and Clang (3.1) both accept it with the pedantic settings: -std=c++11 -Wall -W -pedantic Intel C++ (13.0.1.117) does not. It barks at int baz…
Nikos C.
  • 50,738
  • 9
  • 71
  • 96