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

Jonathan Sauer jonathan.sauer at gmx.de
Mon May 30 04:26:13 PDT 2011


Hello,

>> Driver activates C++ mode depending on executable name
> 
> How can it do this if the files are identical?

If clang is called via the symlink clang++, argv[0] is "clang++" instead of "clang". Look into
driver.cpp, function ParseProgName, where this is checked. There are quite a few supported names
(suffixes, actually).

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

Yes :-)

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

To activate C++ mode, just as Konstantin wrote.

Of course you can simply use "clang" to compile C++ code, too. You just have to pass "-x c++" and
"-lc++" (for libc++) or "-lstdc++" (for libstdc++) to it ("-x c++" is optional if the source file
is recognized (using its extension) as C++ code.


HTH,
Jonathan





More information about the cfe-dev mailing list