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

Using brace-init to initialize a reference to std::shared_ptr

I was working on a code recently and I stumbled on something unusual in GCC and Clang. Using brace-init triggers a compilation error in gcc, while a direct initialization such as &b = a works. The code below is a very simple example of that…
iamOgunyinka
  • 1,040
  • 1
  • 9
  • 17
7
votes
1 answer

Using dladdr in release

Im writing a profiling tool for my App and im using dladdr to convert function pointer to name. Everything work fine as long as Im in debug but as soon as I compile in release (using XCode 5.1) all name conversion fail and return NULL ex: #include…
McBob
  • 1,011
  • 2
  • 13
  • 25
7
votes
3 answers

clang vs gcc - optimization including operator new

I have this simple example I was testing against and I noticed that gcc optimizations (-O3) seems not be as good as clang ones when operator new is involved. I was wondering what might be the issue and if it possible to force gcc to produce more…
Kris
  • 539
  • 3
  • 13
7
votes
0 answers

Objective Sharpie: Binding a framework that imports headers from another library

I'm using Objective Sharpie to bind a framework which imports a header from another framework and this is the error that I get: /Users/sani/Documents/BindMeSDK/BindMeSDK.framework/Versions/A/Headers/BindMeAppLinkResolver.h:19:9: fatal error:…
Sani
  • 1,283
  • 11
  • 30
7
votes
1 answer

Clang doesn't know Doxygens retval tag

I'm trying to compile a C file with clang 3.6 and -Weverything but it fails at my Doxygen comment which includes the \retval tag. My code looks like this: /***************************************************************************/ /** Main…
Sven
  • 7,335
  • 4
  • 15
  • 14
7
votes
0 answers

Clang - "unable to execute command: program not executable"

I'm trying to compile this code: extern "C" void __declspec(dllexport) TEST(int num) { return; } With this command line: clang++ main.cpp -shared -o test.dll and clang is failing to (it appears, anyway) find the linker Verbose output from…
Steve Dell
  • 575
  • 1
  • 7
  • 23
7
votes
1 answer

Can Clang accept LLVM IR or bitcode via pipe?

Clang can accept source files through a pipe if a language is specified with the -x flag. cat hello_world.c | clang -x c -o hello_world Clang can also compile LLVM IR and bitcode to object files clang hello_world.c -S -emit-llvm && clang -o…
7
votes
0 answers

Clang's hasDescendant matcher and deeply nested AST nodes

I want to match any statement that has a call expression as a descendant on the AST. Here is a simple example: int foo() { return 5; } int main() { int a; a = foo(); return 0: } In this example I want to match the a = foo(); statement. In…
Thanasis
  • 107
  • 5
7
votes
1 answer

"Undefined symbols for architecture x86_64:"

I am attempting to compile this library on mac os x Mavericks 10.9.3 64-bit: http://www.openfec.org/downloads.html I followed the README exactly, and got this error: Linking C shared library ../../bin/Release/libopenfec.dylib Undefined symbols…
h4x0rjax
  • 359
  • 1
  • 6
  • 15
7
votes
2 answers

Unable to install GDAL in python 3 using pip (clang failed with exit status 1)

After running sudo pip3.4 install gdal from terminal (Mac OS X Mavericks) I obtain an error message saying that the 'col_port.h' file was not found and displaying the following error: command '/user/bin/clang/ failed with exit status 1 (the full…
7
votes
1 answer

clang++ only compiles C++11 program using boost::format when -std=c++11 option is dropped

Please take a look at the following C++11 snippet: #include int main(int argc, char** argv) { auto s = boost::format(""); return 0; } When I compile it with clang using the -std=c++11 I get the following error: $ clang++…
Philipp Claßen
  • 41,306
  • 31
  • 146
  • 239
7
votes
1 answer

unknown type name 'siginfo_t' with Clang using _POSIX_C_SOURCE 2, why?

Update Turnes out my lecturer will accept code written to the GNU99 standard, so, as User1 pointed out, I used _GNU_SOURCE at the beginning of my program. (See man feature_test_macros for more info.) Thanks for helping me understand! On Ubuntu…
gone
  • 1,079
  • 5
  • 13
  • 31
7
votes
2 answers

Macports on OSX 10.9 - compile with -stdlib=libstdc++

In OSX 10.9 the default -stdlib option for clang++ is libc++, so that's what Macport uses when building packages. Is there any way to tell Macports to use libstdc++ instead? In particular I would like to build OpenCV through Macports so it's using…
Puchatek
  • 1,477
  • 3
  • 15
  • 33
7
votes
2 answers

Clang (OS X) requires "template" keyword in a particular nested declaration, while VS forbids it

I am writing a cross-platform application in two compilers (Clang on Xcode v5.0.2, and Visual Studio 2012 Update 4) and I have run into a scenario in which the two compilers disagree about the required syntax for the use of the template keyword in a…
Dan Nissenbaum
  • 13,558
  • 21
  • 105
  • 181
7
votes
2 answers

libclang returns too much info about function declarations

I have the following code that uses the clang-c API. #include #include #include CXChildVisitResult printVisitor(CXCursor cursor, CXCursor parent, CXClientData client_data) { CXCursor cursor1 =…
user3016814
  • 135
  • 1
  • 8