• Kirill Smelkov's avatar
    libgolang: Provide Nil as alias for std::nullptr_t · 230c81c4
    Kirill Smelkov authored
    This continues 60f6db6f (libgolang: Provide nil as alias for nullptr and
    NULL): I've tried to compile pygolang with Clang on my Debian 10
    workstation and got:
    
        $ CC=clang CXX=clang++ python setup.py build_dso -i
    
        In file included from ./golang/fmt.h:32:
        ./golang/libgolang.h:381:11: error: unknown type name 'nullptr_t'; did you mean 'std::nullptr_t'?
        constexpr nullptr_t nil = nullptr;
                  ^~~~~~~~~
                  std::nullptr_t
        /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8/bits/c++config.h:242:29: note: 'std::nullptr_t' declared here
          typedef decltype(nullptr)     nullptr_t;
                                        ^
        :
        In file included from ./golang/context.h
        In file included from golang/runtime/libgolang.cpp:30:
        ./golang/libgolang.h:381:11: error: unknown type name 'nullptr_t'; did you mean 'std::nullptr_t'?
        constexpr nullptr_t nil = nullptr;
                  ^~~~~~~~~
                  std::nullptr_t
        /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8/bits/c++config.h:242:29: note: 'std::nullptr_t' declared here
          typedef decltype(nullptr)     nullptr_t;
                                        ^
        :39:
        ./golang/libgolang.h:381:11: error: unknown type In file included from golang/fmt.cpp:25:
        In file included from ./golang/fmt.h:32:
        ./golang/libgolang.h:421:17: error: unknown type name 'nullptr_t'; did you mean 'std::nullptr_t'?
            inline chan(nullptr_t) { _ch = nil; }
                        ^~~~~~~~~
                        std::nullptr_t
    
        ...
    
    It seems with GCC and Clang under macOS nullptr_t is automatically provided in
    builtin namespace, while with older Clang on Linux (clang version 7.0.1-8) only
    in std:: namespace - rightfully as nullptr_t is described to be present there:
    
    https://en.cppreference.com/w/cpp/types/nullptr_t
    
    This way we either have to correct all occurrences of nullptr_t to
    std::nullptr_t, or do something similar with providing nil under golang:: .
    
    To reduce noise I prefer the later and let it be named as Nil.
    230c81c4
_context.pxd 3.45 KB