[PyQt] Dealing with GCC/LLVM warning: zero as null pointer constant [-Wzero-as-null-pointer-constant]
Brüns, Stefan
Stefan.Bruens at rwth-aachen.de
Tue Aug 28 19:09:57 BST 2018
On Dienstag, 28. August 2018 19:38:48 CEST Phil Thompson wrote:
> On 28 Aug 2018, at 6:18 pm, Brüns, Stefan <Stefan.Bruens at rwth-aachen.de>
wrote:
> > Hi,
> >
> > current versions of GCC and LLVM issue a warning when 0 is used for a null
> > pointer. This is e.g. the case for generated code using sipCallMethod. The
> > prototype of the underlying api_call_method interface is:
> >
> > PyObject *(*api_call_method)(int *isErr, PyObject *method, const char
> > *fmt,
> > ....)
> >
> > The C++11 way for a correct call would be
> >
> > sipCallMethod(nullptr, ....)
> >
> > , but this only works for C++11 compliant compilers. I have tried
> > different
> > variants and compilers with godbolt:
> >
> > https://godbolt.org/g/6wHC3n
> >
> > , and the most portable one seems to be:
> > ---
> > #if __cplusplus < 201103L
> > #define nullptr 0
> > #endif
> >
> > sipCallMethod(nullptr, ...);
> > ---
> >
> > Any thoughts on this?
>
> What about MSVC compilers? Do they define __cplusplus and give it proper
> values?
>
> Phil
According to
https://msdn.microsoft.com/en-us/library/b0084kay.aspx it is defined for C++,
but has the value 199711 ...
This is fixed with MSVC 15.7 Pre 3:
https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/
_MSVC_LANG can be used meanwhile.
Kind regards,
Stefan
More information about the PyQt
mailing list