bug-gnulib
[Top][All Lists]
Advanced

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

Re: nullptr in C++ mode on macOS


From: Jeffrey Walton
Subject: Re: nullptr in C++ mode on macOS
Date: Thu, 9 Feb 2023 15:38:03 -0500

On Thu, Feb 9, 2023 at 2:31 PM Bruno Haible <bruno@clisp.org> wrote:
>
> On macOS 12.5 (machine: gcc104.fsffrance.org), the test-nullptr-c++.cc fails
> to compile:

One of the sharp edges you may be encountering is, LLVM was shipping a
C++03 compiler by default. You had to do something special to use
C++11 (-std=c++11). And this was in 2016 or 2018. I filed a couple of
bug reports about it.

Then you have Apple's version of Clang. They are probably C++03 for
compatibility reasons for Xcode developers. So even if LLVM moved to
C++11, Apple's Clang may stay at C++03.

> I don't know how to proceed here. C++ is such a waste of time!!

In the projects I work on, I use a library specific define. In
Gnulib's case, it would be GNULIB_NULLPTR. Then I have a feature test
to set GNULIB_NULLPTR to either nullptr or NULL. The strategy works
well for me.

    #if defined(HAVE_CXX11_NULLPTR)
    #   define GNULIB_NULLPTR nullptr
    #else
    #   define GNULIB_NULLPTR NULL
    #endif

Most compilers will use nulltpr nowadays. But Clang may provide
unusual results due to LLVM and Apple pinning the compiler at C++03.

Jeff



reply via email to

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