bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why CXX defaults to g++ instead of c++


From: Lei Zhang
Subject: Re: Why CXX defaults to g++ instead of c++
Date: Thu, 28 Jul 2016 07:30:55 +0800

2016-07-27 23:21 GMT+08:00 Paul Smith <address@hidden>:
> On Wed, 2016-07-27 at 21:39 +0800, Lei Zhang wrote:
>> The problem is, somehow Make defaults CXX to g++ instead of c++, so
>> my solution doesn't work. While CC already defaults to cc, is there
>> any specific reason for CXX not to default to c++?
>
> The POSIX spec defines that "cc" be a C compiler, and that the CC make
> macro be set to it (actually the newer POSIX specs require it be set to
> "c99"; that should be fixed in GNU make).
>
> There's no requirement for a C++ compiler on a POSIX system, and no
> default setting for the CXX variable (in fact that variable isn't
> defined in POSIX).
>
> So, make just uses "g++" by default.  I seem to recall that back in the
> early days of GCC, there was no "c++" installed and only "g++".

Thanks for the explanation. But does it break anything if Make
defaults CXX to c++?

Actually the GNU make shipped in macOS defaults CXX to c++. I guess
they made some modifications to it. That makes sense because macOS has
already ditched gcc in favor of clang as the default compiler.

And last time I tested CMake, it also defaults its CMAKE_CXX_COMPILER to c++.

> If you want a specific C++ compiler, you should set CXX to that value.

Yes, that works. But wouldn't it be better if GNU make just works out
of the box on systems without gcc/g++ (like modern FreeBSD)?


Lei



reply via email to

[Prev in Thread] Current Thread [Next in Thread]