Eliminate -Wzero-as-null-pointer-constant warnings in the headers

This commit is contained in:
Paul Cornett
2020-02-02 23:40:01 -08:00
parent 948ddc6e0f
commit 05183b7099
22 changed files with 59 additions and 59 deletions

View File

@@ -709,7 +709,7 @@ public:
wxDataViewItem GetCurrentItem() const; wxDataViewItem GetCurrentItem() const;
void SetCurrentItem(const wxDataViewItem& item); void SetCurrentItem(const wxDataViewItem& item);
virtual wxDataViewItem GetTopItem() const { return wxDataViewItem(0); } virtual wxDataViewItem GetTopItem() const { return wxDataViewItem(NULL); }
virtual int GetCountPerPage() const { return wxNOT_FOUND; } virtual int GetCountPerPage() const { return wxNOT_FOUND; }
// Currently focused column of the current item or NULL if no column has focus // Currently focused column of the current item or NULL if no column has focus

View File

@@ -1327,7 +1327,7 @@ public:
: m_dc(thdc.m_dc), : m_dc(thdc.m_dc),
m_hdc(thdc.m_hdc) m_hdc(thdc.m_hdc)
{ {
const_cast<TempHDC&>(thdc).m_hdc = 0; const_cast<TempHDC&>(thdc).m_hdc = NULL;
} }
~TempHDC() ~TempHDC()

View File

@@ -231,9 +231,9 @@ public:
// return the platform standard DLL extension (with leading dot) // return the platform standard DLL extension (with leading dot)
static wxString GetDllExt(wxDynamicLibraryCategory cat = wxDL_LIBRARY); static wxString GetDllExt(wxDynamicLibraryCategory cat = wxDL_LIBRARY);
wxDynamicLibrary() : m_handle(0) { } wxDynamicLibrary() : m_handle(NULL) { }
wxDynamicLibrary(const wxString& libname, int flags = wxDL_DEFAULT) wxDynamicLibrary(const wxString& libname, int flags = wxDL_DEFAULT)
: m_handle(0) : m_handle(NULL)
{ {
Load(libname, flags); Load(libname, flags);
} }
@@ -243,7 +243,7 @@ public:
~wxDynamicLibrary() { Unload(); } ~wxDynamicLibrary() { Unload(); }
// return true if the library was loaded successfully // return true if the library was loaded successfully
bool IsLoaded() const { return m_handle != 0; } bool IsLoaded() const { return m_handle != NULL; }
// load the library with the given name (full or not), return true if ok // load the library with the given name (full or not), return true if ok
bool Load(const wxString& libname, int flags = wxDL_DEFAULT); bool Load(const wxString& libname, int flags = wxDL_DEFAULT);
@@ -256,13 +256,13 @@ public:
// detach the library object from its handle, i.e. prevent the object from // detach the library object from its handle, i.e. prevent the object from
// unloading the library in its dtor -- the caller is now responsible for // unloading the library in its dtor -- the caller is now responsible for
// doing this // doing this
wxDllType Detach() { wxDllType h = m_handle; m_handle = 0; return h; } wxDllType Detach() { wxDllType h = m_handle; m_handle = NULL; return h; }
// unload the given library handle (presumably returned by Detach() before) // unload the given library handle (presumably returned by Detach() before)
static void Unload(wxDllType handle); static void Unload(wxDllType handle);
// unload the library, also done automatically in dtor // unload the library, also done automatically in dtor
void Unload() { if ( IsLoaded() ) { Unload(m_handle); m_handle = 0; } } void Unload() { if ( IsLoaded() ) { Unload(m_handle); m_handle = NULL; } }
// Return the raw handle from dlopen and friends. // Return the raw handle from dlopen and friends.
wxDllType GetLibHandle() const { return m_handle; } wxDllType GetLibHandle() const { return m_handle; }
@@ -363,7 +363,7 @@ public:
protected: protected:
// common part of GetSymbol() and HasSymbol() // common part of GetSymbol() and HasSymbol()
void *DoGetSymbol(const wxString& name, bool *success = 0) const; void* DoGetSymbol(const wxString& name, bool* success = NULL) const;
#ifdef wxHAVE_DYNLIB_ERROR #ifdef wxHAVE_DYNLIB_ERROR
// log the error after a dlxxx() function failure // log the error after a dlxxx() function failure

View File

@@ -123,7 +123,7 @@ public:
void Unload(); void Unload();
bool IsLoaded() const { return m_entry && m_entry->IsLoaded(); } bool IsLoaded() const { return m_entry && m_entry->IsLoaded(); }
void *GetSymbol(const wxString &symbol, bool *success = 0) void* GetSymbol(const wxString& symbol, bool* success = NULL)
{ {
return m_entry->GetSymbol( symbol, success ); return m_entry->GetSymbol( symbol, success );
} }

View File

@@ -91,7 +91,7 @@ typedef int wxEventType;
wxEventTableEntry(type, winid, idLast, wxNewEventTableFunctor(type, fn), obj) wxEventTableEntry(type, winid, idLast, wxNewEventTableFunctor(type, fn), obj)
#define wxDECLARE_EVENT_TABLE_TERMINATOR() \ #define wxDECLARE_EVENT_TABLE_TERMINATOR() \
wxEventTableEntry(wxEVT_NULL, 0, 0, 0, 0) wxEventTableEntry(wxEVT_NULL, 0, 0, NULL, NULL)
// generate a new unique event type // generate a new unique event type
extern WXDLLIMPEXP_BASE wxEventType wxNewEventType(); extern WXDLLIMPEXP_BASE wxEventType wxNewEventType();

View File

@@ -66,7 +66,7 @@ public:
virtual bool IsFree() const { return false; } virtual bool IsFree() const { return false; }
// Returns handle. // Returns handle.
virtual WXHANDLE GetResourceHandle() const { return 0; } virtual WXHANDLE GetResourceHandle() const { return NULL; }
#endif // defined(__WXMSW__) #endif // defined(__WXMSW__)
protected: protected:

View File

@@ -257,7 +257,7 @@ public:
// pg is one of wxPAGE_ODD, wxPAGE_EVEN and wx_PAGE_ALL constants. // pg is one of wxPAGE_ODD, wxPAGE_EVEN and wx_PAGE_ALL constants.
// You can set different header/footer for odd and even pages // You can set different header/footer for odd and even pages
void SetFonts(const wxString& normal_face, const wxString& fixed_face, const int *sizes = 0); void SetFonts(const wxString& normal_face, const wxString& fixed_face, const int* sizes = NULL);
// Sets fonts to be used when displaying HTML page. (if size null then default sizes used) // Sets fonts to be used when displaying HTML page. (if size null then default sizes used)
// Sets font sizes to be relative to the given size or the system // Sets font sizes to be relative to the given size or the system

View File

@@ -73,11 +73,11 @@ public:
// create a bitmap compatible with the given HDC (or screen by default) and // create a bitmap compatible with the given HDC (or screen by default) and
// return its handle, the caller is responsible for freeing it (using // return its handle, the caller is responsible for freeing it (using
// DeleteObject()) // DeleteObject())
HBITMAP CreateDDB(HDC hdc = 0) const; HBITMAP CreateDDB(HDC hdc = NULL) const;
// get the handle from the DIB and reset it, i.e. this object won't destroy // get the handle from the DIB and reset it, i.e. this object won't destroy
// the DIB after this (but the caller should do it) // the DIB after this (but the caller should do it)
HBITMAP Detach() { HBITMAP hbmp = m_handle; m_handle = 0; return hbmp; } HBITMAP Detach() { HBITMAP hbmp = m_handle; m_handle = NULL; return hbmp; }
#if defined(__WXMSW__) && wxUSE_PALETTE #if defined(__WXMSW__) && wxUSE_PALETTE
// create a palette for this DIB (always a trivial/default one for 24bpp) // create a palette for this DIB (always a trivial/default one for 24bpp)
@@ -92,7 +92,7 @@ public:
// --------- // ---------
// return true if DIB was successfully created, false otherwise // return true if DIB was successfully created, false otherwise
bool IsOk() const { return m_handle != 0; } bool IsOk() const { return m_handle != NULL; }
// get the bitmap size // get the bitmap size
wxSize GetSize() const { DoGetObject(); return wxSize(m_width, m_height); } wxSize GetSize() const { DoGetObject(); return wxSize(m_width, m_height); }
@@ -121,7 +121,7 @@ public:
// a plain DIB or a DIB section (in which case the last parameter must be // a plain DIB or a DIB section (in which case the last parameter must be
// non NULL) // non NULL)
static HBITMAP ConvertToBitmap(const BITMAPINFO *pbi, static HBITMAP ConvertToBitmap(const BITMAPINFO *pbi,
HDC hdc = 0, HDC hdc = NULL,
const void *bits = NULL); const void *bits = NULL);
// create a plain DIB (not a DIB section) from a DDB, the caller is // create a plain DIB (not a DIB section) from a DDB, the caller is
@@ -242,7 +242,7 @@ private:
inline inline
void wxDIB::Init() void wxDIB::Init()
{ {
m_handle = 0; m_handle = NULL;
m_ownsHandle = true; m_ownsHandle = true;
m_data = NULL; m_data = NULL;

View File

@@ -43,7 +43,7 @@ public:
bool Play(wxDC *dc, wxRect *rectBound = NULL); bool Play(wxDC *dc, wxRect *rectBound = NULL);
// accessors // accessors
virtual bool IsOk() const wxOVERRIDE { return m_hMF != 0; } virtual bool IsOk() const wxOVERRIDE { return m_hMF != NULL; }
wxSize GetSize() const; wxSize GetSize() const;
int GetWidth() const { return GetSize().x; } int GetWidth() const { return GetSize().x; }
@@ -59,7 +59,7 @@ public:
// Detach the HENHMETAFILE from this object, i.e. don't delete the handle // Detach the HENHMETAFILE from this object, i.e. don't delete the handle
// in the dtor -- the caller is now responsible for doing this, e.g. using // in the dtor -- the caller is now responsible for doing this, e.g. using
// Free() method below. // Free() method below.
WXHANDLE Detach() { WXHANDLE h = m_hMF; m_hMF = 0; return h; } WXHANDLE Detach() { WXHANDLE h = m_hMF; m_hMF = NULL; return h; }
// Destroy the given HENHMETAFILE object. // Destroy the given HENHMETAFILE object.
static void Free(WXHANDLE handle); static void Free(WXHANDLE handle);

View File

@@ -65,7 +65,7 @@ public:
underlined, face, encoding); underlined, face, encoding);
} }
wxFont(const wxNativeFontInfo& info, WXHFONT hFont = 0) wxFont(const wxNativeFontInfo& info, WXHFONT hFont = NULL)
{ {
Create(info, hFont); Create(info, hFont);
} }
@@ -90,7 +90,7 @@ public:
encoding)); encoding));
} }
bool Create(const wxNativeFontInfo& info, WXHFONT hFont = 0); bool Create(const wxNativeFontInfo& info, WXHFONT hFont = NULL);
virtual ~wxFont(); virtual ~wxFont();

View File

@@ -36,7 +36,7 @@ public:
{ {
m_width = m_height = m_depth = 0; m_width = m_height = m_depth = 0;
m_handle = 0; m_handle = NULL;
} }
wxGDIImageRefData(const wxGDIImageRefData& data) : wxGDIRefData() wxGDIImageRefData(const wxGDIImageRefData& data) : wxGDIRefData()
@@ -50,7 +50,7 @@ public:
} }
// accessors // accessors
virtual bool IsOk() const wxOVERRIDE { return m_handle != 0; } virtual bool IsOk() const wxOVERRIDE { return m_handle != NULL; }
void SetSize(int w, int h) { m_width = w; m_height = h; } void SetSize(int w, int h) { m_width = w; m_height = h; }
@@ -104,7 +104,7 @@ public:
// accessors // accessors
WXHANDLE GetHandle() const WXHANDLE GetHandle() const
{ return IsNull() ? 0 : GetGDIImageData()->m_handle; } { return IsNull() ? NULL : GetGDIImageData()->m_handle; }
void SetHandle(WXHANDLE handle) void SetHandle(WXHANDLE handle)
{ AllocExclusive(); GetGDIImageData()->m_handle = handle; } { AllocExclusive(); GetGDIImageData()->m_handle = handle; }

View File

@@ -67,7 +67,7 @@ public:
// Low-level invocation function. Pass either an array of variants, // Low-level invocation function. Pass either an array of variants,
// or an array of pointers to variants. // or an array of pointers to variants.
bool Invoke(const wxString& member, int action, bool Invoke(const wxString& member, int action,
wxVariant& retValue, int noArgs, wxVariant args[], const wxVariant* ptrArgs[] = 0) const; wxVariant& retValue, int noArgs, wxVariant args[], const wxVariant* ptrArgs[] = NULL) const;
// Invoke a member function // Invoke a member function
wxVariant CallMethod(const wxString& method, int noArgs, wxVariant args[]); wxVariant CallMethod(const wxString& method, int noArgs, wxVariant args[]);

View File

@@ -162,7 +162,8 @@ protected:
// implicitly convertible to HANDLE, which is a pointer. // implicitly convertible to HANDLE, which is a pointer.
static HANDLE InvalidHandle() static HANDLE InvalidHandle()
{ {
return reinterpret_cast<HANDLE>(INVALID_VALUE); wxUIntPtr h = INVALID_VALUE;
return reinterpret_cast<HANDLE>(h);
} }
void DoClose() void DoClose()
@@ -449,7 +450,7 @@ private:
class MemoryHDC class MemoryHDC
{ {
public: public:
MemoryHDC(HDC hdc = 0) { m_hdc = ::CreateCompatibleDC(hdc); } MemoryHDC(HDC hdc = NULL) { m_hdc = ::CreateCompatibleDC(hdc); }
~MemoryHDC() { ::DeleteDC(m_hdc); } ~MemoryHDC() { ::DeleteDC(m_hdc); }
operator HDC() const { return m_hdc; } operator HDC() const { return m_hdc; }
@@ -483,7 +484,7 @@ public:
~SelectInHDC() { if ( m_hdc ) ::SelectObject(m_hdc, m_hgdiobj); } ~SelectInHDC() { if ( m_hdc ) ::SelectObject(m_hdc, m_hgdiobj); }
// return true if the object was successfully selected // return true if the object was successfully selected
operator bool() const { return m_hgdiobj != 0; } operator bool() const { return m_hgdiobj != NULL; }
private: private:
HDC m_hdc; HDC m_hdc;
@@ -578,7 +579,7 @@ class MonoBitmap : public AutoHBITMAP
{ {
public: public:
MonoBitmap(int w, int h) MonoBitmap(int w, int h)
: AutoHBITMAP(::CreateBitmap(w, h, 1, 1, 0)) : AutoHBITMAP(::CreateBitmap(w, h, 1, 1, NULL))
{ {
} }
}; };

View File

@@ -136,7 +136,7 @@ public:
size_t *pnValues, // number of values size_t *pnValues, // number of values
size_t *pnMaxValueLen) const; size_t *pnMaxValueLen) const;
// return true if the key is opened // return true if the key is opened
bool IsOpened() const { return m_hKey != 0; } bool IsOpened() const { return m_hKey != NULL; }
// for "if ( !key ) wxLogError(...)" kind of expressions // for "if ( !key ) wxLogError(...)" kind of expressions
operator bool() const { return m_dwLastError == 0; } operator bool() const { return m_dwLastError == 0; }

View File

@@ -453,7 +453,7 @@ public:
// The brush returned from here must remain valid at least until the next // The brush returned from here must remain valid at least until the next
// event loop iteration. Returning 0, as is done by default, indicates // event loop iteration. Returning 0, as is done by default, indicates
// there is no custom background brush. // there is no custom background brush.
virtual WXHBRUSH MSWGetCustomBgBrush() { return 0; } virtual WXHBRUSH MSWGetCustomBgBrush() { return NULL; }
// this function should return the brush to paint the children controls // this function should return the brush to paint the children controls
// background or 0 if this window doesn't impose any particular background // background or 0 if this window doesn't impose any particular background

View File

@@ -150,7 +150,7 @@ name##PluginSentinel m_pluginsentinel
// The 'this' pointer is always true, so use this version // The 'this' pointer is always true, so use this version
// to cast the this pointer and avoid compiler warnings. // to cast the this pointer and avoid compiler warnings.
#define wxDynamicCastThis(className) \ #define wxDynamicCastThis(className) \
(IsKindOf(&className::ms_classInfo) ? (className *)(this) : (className *)0) (IsKindOf(&className::ms_classInfo) ? (className*)this : NULL)
template <class T> template <class T>
inline T *wxCheckCast(const void *ptr) inline T *wxCheckCast(const void *ptr)

View File

@@ -52,13 +52,13 @@ public:
// If you pass a palette pointer, you must free the palette yourself. // If you pass a palette pointer, you must free the palette yourself.
static bool Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalette, int desiredNoColours = 236, static bool Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalette, int desiredNoColours = 236,
unsigned char** eightBitData = 0, int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE|wxQUANTIZE_RETURN_8BIT_DATA); unsigned char** eightBitData = NULL, int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE|wxQUANTIZE_RETURN_8BIT_DATA);
// This version sets a palette in the destination image so you don't // This version sets a palette in the destination image so you don't
// have to manage it yourself. // have to manage it yourself.
static bool Quantize(const wxImage& src, wxImage& dest, int desiredNoColours = 236, static bool Quantize(const wxImage& src, wxImage& dest, int desiredNoColours = 236,
unsigned char** eightBitData = 0, int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE|wxQUANTIZE_RETURN_8BIT_DATA); unsigned char** eightBitData = NULL, int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE|wxQUANTIZE_RETURN_8BIT_DATA);
//// Helpers //// Helpers

View File

@@ -62,7 +62,7 @@ public:
~wxClassInfo(); ~wxClassInfo();
wxObject *CreateObject() const wxObject *CreateObject() const
{ return m_objectConstructor ? (*m_objectConstructor)() : 0; } { return m_objectConstructor ? (*m_objectConstructor)() : NULL; }
bool IsDynamic() const { return (NULL != m_objectConstructor); } bool IsDynamic() const { return (NULL != m_objectConstructor); }
const wxChar *GetClassName() const { return m_className; } const wxChar *GetClassName() const { return m_className; }

View File

@@ -598,7 +598,7 @@ public:
protected: protected:
// exits from the current thread - can be called only from this thread // exits from the current thread - can be called only from this thread
void Exit(ExitCode exitcode = 0); void Exit(ExitCode exitcode = NULL);
// entry point for the thread - called by Run() and executes in the context // entry point for the thread - called by Run() and executes in the context
// of this thread. // of this thread.

View File

@@ -247,7 +247,7 @@ protected:
virtual wxString GetResourceType() const { return "MOFILE"; } virtual wxString GetResourceType() const { return "MOFILE"; }
// returns module to load resources from // returns module to load resources from
virtual WXHINSTANCE GetModule() const { return 0; } virtual WXHINSTANCE GetModule() const { return NULL; }
}; };
#endif // __WINDOWS__ #endif // __WINDOWS__

View File

@@ -840,7 +840,7 @@ WXDLLIMPEXP_CORE bool wxYieldIfNeeded();
size_t *outLen, size_t *outLen,
const wxString& resourceName, const wxString& resourceName,
const wxChar* resourceType = wxUserResourceStr, const wxChar* resourceType = wxUserResourceStr,
WXHINSTANCE module = 0); WXHINSTANCE module = NULL);
// This function allocates a new buffer and makes a copy of the resource // This function allocates a new buffer and makes a copy of the resource
// data, remember to delete[] the buffer. And avoid using it entirely if // data, remember to delete[] the buffer. And avoid using it entirely if
@@ -851,7 +851,7 @@ WXDLLIMPEXP_CORE bool wxYieldIfNeeded();
wxLoadUserResource(const wxString& resourceName, wxLoadUserResource(const wxString& resourceName,
const wxChar* resourceType = wxUserResourceStr, const wxChar* resourceType = wxUserResourceStr,
int* pLen = NULL, int* pLen = NULL,
WXHINSTANCE module = 0); WXHINSTANCE module = NULL);
#endif // __WINDOWS__ #endif // __WINDOWS__
#endif #endif

View File

@@ -858,9 +858,14 @@ template<> struct wxStrtoxCharType<std::nullptr_t>
template<typename T> template<typename T>
inline double wxStrtod(const wxString& nptr, T endptr) inline double wxStrtod(const wxString& nptr, T endptr)
{ {
// Explicit comparison with 0 required when using T=nullptr with MSVS 2012. if (!endptr)
if (endptr != 0)
{ {
// when we don't care about endptr, use the string representation that
// doesn't require any conversion (it doesn't matter for this function
// even if its UTF-8):
wxStringCharType** p = NULL;
return wxStrtod(nptr.wx_str(), p);
}
// note that it is important to use c_str() here and not mb_str() or // note that it is important to use c_str() here and not mb_str() or
// wc_str(), because we store the pointer into (possibly converted) // wc_str(), because we store the pointer into (possibly converted)
// buffer in endptr and so it must be valid even when wxStrtod() returns // buffer in endptr and so it must be valid even when wxStrtod() returns
@@ -868,12 +873,6 @@ inline double wxStrtod(const wxString& nptr, T endptr)
return wxStrtod((CharType)nptr.c_str(), return wxStrtod((CharType)nptr.c_str(),
wxStrtoxCharType<T>::AsPointer(endptr)); wxStrtoxCharType<T>::AsPointer(endptr));
} }
// when we don't care about endptr, use the string representation that
// doesn't require any conversion (it doesn't matter for this function
// even if its UTF-8):
wxStringCharType** p = NULL;
return wxStrtod(nptr.wx_str(), p);
}
template<typename T> template<typename T>
inline double wxStrtod(const wxCStrData& nptr, T endptr) inline double wxStrtod(const wxCStrData& nptr, T endptr)
{ return wxStrtod(nptr.AsString(), endptr); } { return wxStrtod(nptr.AsString(), endptr); }
@@ -891,16 +890,16 @@ inline double wxStrtod(const wxCStrData& nptr, T endptr)
template<typename T> \ template<typename T> \
inline rettype name(const wxString& nptr, T endptr, int base) \ inline rettype name(const wxString& nptr, T endptr, int base) \
{ \ { \
if (endptr) \ if (!endptr) \
{ \ { \
wxStringCharType** p = NULL; \
return name(nptr.wx_str(), p, base); \
} \
typedef typename wxStrtoxCharType<T>::Type CharType; \ typedef typename wxStrtoxCharType<T>::Type CharType; \
return name((CharType)nptr.c_str(), \ return name((CharType)nptr.c_str(), \
wxStrtoxCharType<T>::AsPointer(endptr), \ wxStrtoxCharType<T>::AsPointer(endptr), \
base); \ base); \
} \ } \
wxStringCharType** p = NULL; \
return name(nptr.wx_str(), p, base); \
} \
template<typename T> \ template<typename T> \
inline rettype name(const wxCStrData& nptr, T endptr, int base) \ inline rettype name(const wxCStrData& nptr, T endptr, int base) \
{ return name(nptr.AsString(), endptr, base); } { return name(nptr.AsString(), endptr, base); }