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
100
votes
8 answers

Suppress warning "Category is implementing a method which will also be implemented by its primary class"

I was wondering how to suppress the warning: Category is implementing a method which will also be implemented by its primary class. I have this for a specific code category: + (UIFont *)systemFontOfSize:(CGFloat)fontSize { return [self…
Doz
  • 7,009
  • 12
  • 61
  • 69
96
votes
14 answers

Compile, Build or Archive problems with Xcode 4 (and dependencies)

This question has evolved over the past several weeks to cover more general issues with xcode4 (and upgrading projects form older xcodes). However many of the issues can be solved by following the same set of instructions. If you have any of the…
Richard Stelling
  • 25,607
  • 27
  • 108
  • 188
95
votes
13 answers

LLVM C++ IDE for Windows

Is there some C/C++ IDE for Windows, which is integrated with the LLVM compiler (and Clang C/C++ analyzer), just like modern Xcode do. I have Dev-Cpp (it uses outdated GCC) and Code::Blocks (with some GCC). But GCC gives me very cryptic error…
osgx
  • 90,338
  • 53
  • 357
  • 513
90
votes
2 answers

Is this floating-point optimization allowed?

I tried to check out where float loses the ability to exactly represent large integer numbers. So I wrote this little snippet: int main() { for (int i=0; ; i++) { if ((float)i!=i) { return i; } } } This code…
geza
  • 28,403
  • 6
  • 61
  • 135
86
votes
4 answers

Can I use C++11 with Xcode?

I am considering the use of some C++11 features (like auto for instance) in some cross-platform projects (Windows+Mac). On Windows, Visual Studio supports parts of the upcoming C++11 standard that would allow me to simplify parts of the code base so…
villintehaspam
  • 8,540
  • 6
  • 45
  • 76
85
votes
1 answer

What is the meaning of clang's -Wweak-vtables?

I basically do not understand clang's -Wweak-vtables. Here is what I observed so far: Case one: (triggers the warning) class A { public: virtual ~A(){} }; class B : public A { public: virtual ~B(){} }; int main(){} Case…
Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
84
votes
7 answers

What's the proper way to enable AddressSanitizer in CMake that works in Xcode

I've added AddressSanitizer flag as follow: set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") Everything builds and runs fine when using Unix Makefiles. The problem comes when generating the Xcode project, it just doesn't want to link…
ObjSal
  • 1,494
  • 1
  • 14
  • 18
83
votes
2 answers

How to detect SSE/SSE2/AVX/AVX2/AVX-512/AVX-128-FMA/KCVI availability at compile-time?

I'm trying to optimize some matrix computations and I was wondering if it was possible to detect at compile-time if SSE/SSE2/AVX/AVX2/AVX-512/AVX-128-FMA/KCVI[1] is enabled by the compiler ? Ideally for GCC and Clang, but I can manage with only one…
Baptiste Wicht
  • 7,472
  • 7
  • 45
  • 110
79
votes
2 answers

static variable link error

I'm writing C++ code on a mac. Why do I get this error when compiling?: Undefined symbols for architecture i386: "Log::theString", referenced from: Log::method(std::string) in libTest.a(Log.o) ld: symbol(s) not found for architecture…
subzero
  • 3,420
  • 5
  • 31
  • 40
79
votes
4 answers

Why is -march=native used so rarely?

With most C/C++ compilers, there's a flag passable to the compiler, -march=native, which tells the compiler to tune generated code for the micro-architecture and ISA extensions of the host CPU. Even if it doesn't go by the same name, there's…
lcmylin
  • 2,552
  • 2
  • 19
  • 31
79
votes
5 answers

Clang-format line breaks

I'm looking for a clang-format setting to prevent the tool from removing line breaks. For example, I have my ColumnLimit set to 120, and here's what happens when I reformat some sample code. Before: #include #include…
zmb
  • 7,605
  • 4
  • 40
  • 55
78
votes
4 answers

Ignore all warnings in a specific file using LLVM/Clang

There are some files in my iOS project that have some warnings, and I want to ignore those warnings. I don't want to disable warnings in the entire project (know how to do that), just some specific files. So, is there a way to completely ignore all…
bobbypage
  • 2,157
  • 2
  • 21
  • 21
78
votes
2 answers

Can clang format add braces to single line if statements etc

Is there an option for clang-format to add braces to all if()/do/while statements etc? eg if( i == 42 ) std::cout << "You found the meaning of life\n"; else std::cout << "Wrong!\n"; to if( i == 42 ) { std::cout << "You found the meaning of…
Adrian Cornish
  • 23,227
  • 13
  • 61
  • 77
77
votes
3 answers

How to generate assembly code with clang in Intel syntax?

As this question shows, with g++, I can do g++ -S -masm=intel test.cpp. Also, with clang, I can do clang++ -S test.cpp, but -masm=intel is not supported by clang (warning argument unused during compilation: -masm=intel). How do I get intel syntax…
Jesse Good
  • 50,901
  • 14
  • 124
  • 166
76
votes
10 answers

macOS 'wchar.h' File Not Found

Under OS X 10.9.5 using XCode 6.0.1 I am running into the following issue when I try to run make from the terminal: fatal error: 'wchar.h' file not found This issue was not happening prior to a recent upgrade to Mavericks.
ssell
  • 6,429
  • 2
  • 34
  • 49