Questions tagged [clang]

compiler front end for C, C++, Objective-C

Clang is an "LLVM native" C/C++/Objective-C compiler, which aims to deliver amazingly fast compiles, extremely useful error and warning messages and to provide a platform for building great source level tools.

15 questions
102
votes
5 answers

Clang warning flags for Objective-C development

As a C & Objective-C programmer, I'm a bit paranoid with the compiler warning flags. I usually try to find a complete list of warning flags for the compiler I use, and turn most of them on, unless I have a really good reason not to turn it on. I…
Macmade
  • 1,146
  • 2
  • 8
  • 12
26
votes
4 answers

GCC vs clang/LLVM -- pros and cons of each

What are the pros and cons of GCC vs clang/LLVM?
yodie
  • 694
  • 1
  • 7
  • 12
18
votes
1 answer

Why does LLVM have an assembly-like IR rather than a tree-like IR? Or: why do projects target LLVM IR instead of clang's AST?

Why is LLVM's intermediate representation (LLVM IR) assembly-like rather than tree-like? Alternatively, why do language implementations target LLVM IR rather than clang's AST? I'm not trying to ask two different questions at once if it seems that…
Praxeolitic
  • 1,604
  • 3
  • 15
  • 24
12
votes
3 answers

C++: Metaprogramming with a compiler API rather than with C++ features

This started out as a SO question but I realized that it is quite unconventional and based on the actual description on the websites, it might be better suited to programmers.se since the question has a lot of conceptual weight. I have been…
Steven Lu
  • 509
  • 4
  • 11
9
votes
3 answers

Is Clang/LLVM ready for prime time?

Clang is able to be used instead of gcc? What your experience on that? What disadvantages there are yet? Performance of compilation is very better than gcc but about performance of code generated when executing it? Are there good tools as front-end…
Maniero
  • 10,826
  • 14
  • 80
  • 133
8
votes
2 answers

Is it wise to use Clang for personal code analysis in a project that builds with gcc?

I started to work on several C projects that are building using gcc. I believe this choice was made for several reasons: Had to cross-compile for arm very early on (I think). Performance is the first and foremost spec. gcc was and is still the easy…
nathdwek
  • 271
  • 1
  • 4
7
votes
4 answers

Reason to use mingw win32 headers and libs with LLVM/Clang

Is there any good reason (except "GCC is better") to use the MinGW win32api/headers/libs with LLVM/Clang. Suppose that in two to three years, Clang has matured enough (in C++0x and performance) that it's a competitor/replacement and has its…
rubenvb
  • 580
  • 5
  • 15
2
votes
1 answer

Does an explicit temporary of an integral type qualify as an integral constant expression?

In the following code, int() is an explicit type conversion. #include int main() { void* ptr = int(); return 0; } Clang Compiler: source_file.cpp:5:11: error: cannot initialize a variable of type 'void *' with an rvalue of…
Jemes
  • 133
  • 4
2
votes
1 answer

How are objects stored in unordered_sets?

I've been doing a bit of research on the subject. I know unordered_sets are hash tables, where the key and value are one and the same. What I'd like to know is how the compiler figures out where in the table each object belongs.
moonman239
  • 2,023
  • 4
  • 18
  • 23
2
votes
1 answer

Why isn't the isa pointer hardwired in Objective-C classes?

I've been studying the Objective-C runtime for some years, and even hacked libobjc a little bit (both Apple's and GNUStep's), and I've been wondering about a design decision on the compilers. Every Objective-C object is expected to have its size at…
paulotorrens
  • 173
  • 5
1
vote
1 answer

Switching out implementation source files in C project

For simplicity, let's say I have the following C project structure: src/ utils/ logger.c logger.h main.c secondary_component.c main.c starts with: #include "utils/logger.h" I would like to keep the code and its structure as-is, but…
ChaimKut
  • 123
  • 4
1
vote
2 answers

How to prevent 'global variables' in a big project?

With 'global variables', I mean Variables on namespace level Static data members in classes Static variables in functions In a big C++ project I would like to have a mechanism (like a compiler option) to prevent such data in most parts. A compiler…
Borph
  • 121
  • 3
1
vote
1 answer

Cross compiling: Share compile steps between different target platforms?

For a C project, I'm upgrading my build process from MingGW-GCC / make and Android Studio under Windows (2 separate processes) to Clang / CMake under Debian 8, using wclang and wine to compile and run the Windows build It seems to me as if we…
Engineer
  • 767
  • 5
  • 16
1
vote
2 answers

How could Clang release under BSD license?

I found that llvm could only generate assembly code. If someone want generate and link assembly code to native executable code, they should use external tool(GNU as/ld, for example. Currently lld is not ready, and there no more information about…
sunny2016
  • 113
  • 3
0
votes
1 answer

When is it a good idea to test a build with both clang and gcc?

I am peeking through the code of torsocks where as you'll notice, the .travis.yml file instructs Travis CI to test against both clang and gcc. compiler: - clang - gcc I'm still learning and this caught my attention. Why both? Why not just one…
Alex V
  • 111
  • 4