Clang, LLVM and g ++

I installed clang to compare its use with g ++ (gcc) for some C ++ programs; as in, I compared compile time, error feedback, etc. for the same programs. I did this mainly for the official LLVM tutorial (compiler implementation using LLVM).

At some point, I needed to install the LLVM libraries (version 2.9.), And before I just downloaded clang. Because of this, compiling with clang ++ does not seem to work for the following tutorial code; while g ++ works with LLVM directives (e.g. 'llvm-config -libs`, etc.). Along with installing the libraries, I also had to switch from the old tutorial I was reading (llvm 2.2., Suggesting clang ++ syntax), to one for 3.0. (assuming g ++ syntax) as the changes in the library have been changed.

My questions to explain the changes after loading llvm libs:

(1) When I type 'g ++' now, am I still actually working with gcc or will llvm / clang set itself as the new default mimicking gcc syntax? If so, how can I make sure that I really use gcc and not clang when I want?

(2) If g ++ is still gcc, any opinions / guess why the official clang / llvm manual is switching from suggesting to use its own competing compiler back to gcc? (e.g. here )

My system:

Ubuntu 12.04.
llvm 2.9.
gcc 4.6.3.
clang 3.0.

+4
source share
1 answer

To type g++clang to run the compiler, you will probably look for either a symbolic link named g++for clang earlier in your $PATHthan the path to the real one g++, or an alias with the name g++, line by line alias g++='clang++'.

( , ), alias g++, , - ( , )

$PATH, , ( , clang, clang++ g++) PATH, , , /usr/local/bin - , !

, , g++ gcc g++, - - g++ , , ?

+1

Source: https://habr.com/ru/post/1526649/


All Articles