Build failed due to NULL pointer redefinition in C++
The build of my project failed after updating to latest version of glib (2.76.1).
The error is triggered by a functions defined in the gdiplusimageattributes.h header of windows dev kit where NULL
is passed to a Gdiplus::ARGB
argument.
1>------ Build started: Project: clipboardtool, Configuration: Release Win32 ------
1>main.cpp
1>c:\users\ignazp\code\dcv\deps\gtk-binaries-server-windows\x64\release\include\glib-2.0\glib\gstring.h(233): warning C4244: 'argument': conversion from 'gsize' to 'size_t', possible loss of data
1>c:\users\ignazp\code\dcv\deps\gtk-binaries-server-windows\x64\release\include\glib-2.0\glib\gstring.h(235): warning C4244: 'argument': conversion from 'gsize' to 'size_t', possible loss of data
1>c:\program files (x86)\windows kits\10\include\10.0.18362.0\um\gdiplusimageattributes.h(239): error C2664: 'Gdiplus::GpStatus Gdiplus::DllExports::GdipSetImageAttributesColorKeys(Gdiplus::GpImageAttributes *,Gdiplus::ColorAdjustType,BOOL,Gdiplus::ARGB,Gdiplus::ARGB)': cannot convert argument 4 from 'nullptr' to 'Gdiplus::ARGB'
1>c:\program files (x86)\windows kits\10\include\10.0.18362.0\um\gdiplusimageattributes.h(244): note: A native nullptr can only be converted to bool or, using reinterpret_cast, to an integral type
1>Done building project "testgdi.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The issue can be reproduce with this code sample: main.cpp.
The issue is not reproduced if we include glib.h
as last header.
The root cause of the issue is a change introduced in the latest version of glib, now NULL
is redefined as (nullptr)
for C++11 cases.
See 0ca5254c
Expected behavior:
- No regression with respect previous glib version
- The build result should not depend on included files order
Edited by ignazp