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

std::bind to a std::function crashes with Clang

I'm having trouble understanding some subtleties when combining std::bind with std::function. I have minimized my problems to the following code snippet: #include #include void bar(int x) { std::cout << "Hello." <<…
villintehaspam
  • 8,540
  • 6
  • 45
  • 76
7
votes
1 answer

Nested class hidden by multiple inheritance

Is this code valid C++(11)? struct Base { template struct nested; }; struct Derived1 : Base { }; struct Derived2 : Base { }; struct Derived3 : Derived1, Derived2 { }; typedef Derived3::nested xxx; What I know The above code…
Louis Dionne
  • 3,104
  • 1
  • 15
  • 35
7
votes
2 answers

template template parameters and clang

I have had problems (possibly mine) with template template parameters and clang. The following toy example compiles and runs under g++ 4.7.0, not clang++ 3.0 (based on LLVM 3.0), both ubuntu 12.04. Toy example (test_1.cpp): #include
Charles Pehlivanian
  • 2,083
  • 17
  • 25
7
votes
1 answer

clang can't parse my .h file standalone

I'm using python binding of libclang but I think this problem is caused by libclang not by python binding. I have a header object.h #ifndef OBJECT_H #define OBJECT_H class Object { public: int run(); }; #endif And a implementation…
Ray Wu
  • 993
  • 16
  • 34
7
votes
3 answers

Unable to cross-compile to SPARC using clang

So here's the situation: I need to be able to compile binaries from a Linux machine (on Ubuntu, for what it's worth) which are able to run from a SPARC server. The program I'm trying to compile is very simple: #include #include…
eezstreet
  • 119
  • 1
  • 10
7
votes
2 answers

Is it possible to link bitcode with llvm-ar archieve into a single bitcode file?

I have read this thread on llvm-dev and is faced with the same problem: I cannot link the llvm-ar archieve library with other bitcode files into another single bitcode file with the help of llvm-link. clang -emit-llvm -g -c -o main.bc main.c clang…
Hongxu Chen
  • 5,240
  • 2
  • 45
  • 85
7
votes
1 answer

forcing clang to emit code for never-referenced static member function of class-template instantiation

I can easily achieve this in gcc using the used and noinline function attributes (see code below), but this doesn't work in clang even though it's supposed to support both of these function attributes. A simplified example: template
etherice
  • 1,761
  • 15
  • 25
7
votes
1 answer

Trying to port GCC specific asm goto to Clang

I've been trying to turn a bit of GNU extensions in to actual standard C so it'll run on clang, knowing standard C and not GNU extensions, I'm at a bit of a loss. __asm__ (goto("1:" STATIC_KEY_INITIAL_NOP ".pushsection…
stqism
  • 73
  • 1
  • 3
7
votes
1 answer

Installing Clang/LLVM/Ubuntu

I am required to use LLVM and Clang for a compilers class I am enrolled in. This is not a question about the content of the class, just how to get the required software installed. I am running gcc version 4.6.3 and have downloaded, built, tested,…
Mike T
  • 482
  • 1
  • 6
  • 16
7
votes
1 answer

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

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…
user2642459
  • 507
  • 3
  • 10
  • 18
7
votes
1 answer

Conditionally Hide Code from the Compiler

So here's the problem. I'm set to release an update soon for iOS that will address some problems in iOS 7. In order to do this, I need to use some specific iOS 7 functions/types. I've made absolutely certain that iOS 7 code will only be executed…
Aaron Hayman
  • 8,492
  • 2
  • 36
  • 63
7
votes
1 answer

Better way to load vectors from memory. (clang)

I'm writing a test program to get used to Clang's language extensions for OpenCL style vectors. I can get the code to work but I'm having issues getting one aspect of it down. I can't seem to figure out how to get clang to just load in a vector from…
BlamKiwi
  • 2,093
  • 2
  • 19
  • 30
7
votes
1 answer

Cannot use libclang with Qt

I encountered a strange bug when I tried to use libclang in a Qt application. test.cpp #include #include #include int main (int argc, char *argv[]) { QApplication a(argc, argv); QMainWindow…
silviubogan
  • 3,343
  • 3
  • 31
  • 57
7
votes
2 answers

libclang get class name from cursor

I am trying to extract the class name of a parameter to a method call in objective-C. The code I am parsing is: - (void)testAddConcreteDataModel:(DFDemoDataModelOne*)helpmeh { [self.dataModels addObject:helpmeh]; } And the result I need is the…
Sam
  • 3,659
  • 3
  • 36
  • 49
7
votes
3 answers

Unused parameter warning

I am getting "unused parameter 'testString'" warning from following code. But I am using testString to log. So how come it is unused ? - (void)getString:(NSString *)testString { ICELogInfo(@"%@", testString); } ICELogInfo is a macro for…
AAV
  • 3,785
  • 8
  • 32
  • 59