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
3 answers

cast from sockaddr * to sockaddr_in * increases required alignment

The compiler produces this warning when I'm working with some code which looks like - .... for(p = res; p != NULL; p = p->ai_next) { void *addr; std::string ipVer = "IPv0"; if(p->ai_family == AF_INET) { ipVer …
Abhinav Gauniyal
  • 7,034
  • 7
  • 50
  • 93
7
votes
3 answers

What's the data-type of C enum of Clang compiler?

I posted other question: What type should I use for binary representation of C enum?, and by the answer, I have to know my compiler's enum data-type. What's the data-type of C enum on Clang compiler?
eonil
  • 83,476
  • 81
  • 317
  • 516
7
votes
2 answers

Can't build Google Test with Visual Studio 2015 and Clang 3.7 with Microsoft CodeGen

Using VS 2015 and its new built-in clang toolset / project template, I cannot build Google Test successfully. I get the following errors: Error use of undeclared identifier 'chdir'; did you mean '_chdir'? Error use of undeclared…
WhittlesJr
  • 122
  • 8
7
votes
1 answer

Object cannot be assigned because its copy assignment operator is implicitly deleted error

In my small arkanoid clone game I'm trying to erase some values from a vector. This vector contains Brick classes, that are instantiated on the screen in a grid like pattern. When a collision happens between the ball and a brick, the brick needs to…
Ernst
  • 83
  • 1
  • 1
  • 4
7
votes
1 answer

Why do clang and gcc handle braced-initialization of structs with in-class initialization differently?

I recently discovered an odd behavior of clang and gcc. I have a struct (MyClass) which uses in-class initialization for one of its members (active): struct MyClass { int something; bool active = true; }; Now I try to brace-initialize this…
user3684240
  • 1,420
  • 2
  • 12
  • 18
7
votes
1 answer

Problems installing Clang in windows

I've been trying to install clang in virtual machine with windows xp, first I try with the Pre-Built Binaries of clang for Windows from this page: LLVM Download and I was getting this error: Failed to find MSBuild toolset directory So, I try to…
SujaM
  • 409
  • 6
  • 16
7
votes
2 answers

ld: -bundle and -bitcode_bundle cannot be used together

i'm building llvm/clang 3.7 with bitcode support (-fembed-bitcode). Some modules can't be linked due to error: ld: -bundle and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together clang: error: linker command failed with…
4ntoine
  • 19,816
  • 21
  • 96
  • 220
7
votes
3 answers

How can I align function parameter names in clang-format?

Is it possible to use clang-format to format struct members and function parameter names into columns? For example: struct { int alpha; //aligned to 'b' of "beta" unsigned int beta; MyObject *gamma; //aligned with 'g' not…
lanoxx
  • 12,249
  • 13
  • 87
  • 142
7
votes
3 answers

Is it standard behaviour that adding const to size_t can cause compile failure?

I recently read cool article: https://akrzemi1.wordpress.com/2015/08/20/can-you-see-the-bug/ Playing with reduced version on ideone I got surprising behaviour: #include #include using namespace std; int main() { const size_t…
NoSenseEtAl
  • 28,205
  • 28
  • 128
  • 277
7
votes
2 answers

Compile c++ files for all iOS architectures

I have some cpp files that I would like to compile it in order to run on simulator and iPhone. What I am trying to do is: g++ -c file1.cpp file2.cpp -std=c++11 ar rcs libabc.a *.o And this compiles fine but only for x86_64…
Grace
  • 1,265
  • 21
  • 47
7
votes
1 answer

Is this incorrect use of std::bind or a compiler bug?

I am using the latest snapshot build of clang with latest TDM-Gcc headers and libs. When compiling this (using -std=c++11 flag): #include #include class Foo { public: void Bar(int x) { …
Fr0stBit
  • 1,455
  • 1
  • 13
  • 22
7
votes
1 answer

Building Clang on Windows: DiagnosticCommonKinds.inc header doesn't exist

I'm trying to build Clang on Windows 8.1 with MS Visual Studio 2013 following instructions at http://clang.llvm.org/get_started.html in "Using Visual Studio" section. I have checked out llvm to D:\Current\llvm, clang to D:\Current\llvm\tools\clang,…
leo
  • 549
  • 5
  • 12
7
votes
1 answer

auto and brace initialization in C++11/C++14

When I compile the below code with clang and gcc T is deduced differently. #include //for clang //to see how T is deduced(form compiler error). template void foo(T); int main() { auto var1{2}; …
Praveen
  • 8,945
  • 4
  • 31
  • 49
7
votes
2 answers

Static library link issue with Mac OS X: symbol(s) not found for architecture x86_64

I'm trying to generate a static library and link it with an execution binary. This is a library function: #include int hello() { return 10; } With these commands, I could get a static library. gcc -c io.c ar -crv libio.a…
prosseek
  • 182,215
  • 215
  • 566
  • 871