[cfe-dev] RFC: Clang driver redesign

Christopher Jefferson chris at bubblescope.net
Wed Nov 9 06:50:46 PST 2011


On 8 Nov 2011, at 17:16, David Chisnall wrote:

> On 8 Nov 2011, at 16:50, Jean-Daniel Dupas wrote:
> 
>> As previously suggested in this discussion, I think it could be even better if clang can decide if it uses C or C++ mode not only based on the driver name, but also based on the compiled file language.
>> 
>> clang -o hello hello.cpp
>> 
>> should not result in nasty linker errors as it already knows it is compiling c++.
> 
> You'll still encounter problems if you do:
> 
> clang -c hello.cpp
> clang -o hello hello.o
> 
> Which is what even a trivial Makefile of the form that students are usually expected to submit in their first C or C++ assignment will do if you use clang instead of clang++ for linking.  With your suggestion, it actually becomes worse, because now clang does work for linking C++ in some cases, but not in others.  

True. I'm not sure of the best way of handling this.

To be honest, I would just prefer a nicer error / warning message. Making some attempt to inform the user of their (extremely common) mistake, and how they could go about fixing it, would make life much better for users. I'm not sure of the best place for this to live (clang? linker?) Of course it also isn't necessary to catch all cases, just some basic guidance.


Chris



More information about the cfe-dev mailing list