[cfe-dev] Difference between clang and clang++

Matthieu Moy Matthieu.Moy at grenoble-inp.fr
Mon May 30 04:37:26 PDT 2011


Nikola Smiljanic <popizdeh at gmail.com> writes:

> On Mon, May 30, 2011 at 11:47 AM, Konstantin Tokarev <annulen at yandex.ru> wrote:
>
>     Driver activates C++ mode depending on executable name
>
> How can it do this if the files are identical?

int main(int argc, char **argv) {
	// argv[0] tells you.

clang is not the only one to do this kind of things. For example, on my
system, pdflatex is a symbolic link to latex, although they do different
things.

> And if clang++ is only a symlink that would mean that one executable
> contains all the functionality?

Sure.

> If this is the case, what is the reason behind two names?

C++ is not a superset of C, so compiling C and C++ are different tasks,
although much of the C-compiling code can be re-used for C++.

Clang could as well have shipped one binary, and ask users to say
"clang" or "clang -x c++", but "clang++" is shorter to type.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/



More information about the cfe-dev mailing list