# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1671408426 0 # Node ID e62fc9b3b09cb17174364c091a417b11593d733b # Parent 4b7c4cd7a11d3e47403c1bdab265b76b773d7705 C++: Add DW_NULL which is nullptr on C++11 and NULL on older versions. This allows compilation on Visual C 2005 and hopefully ancient versions of GCC. diff -r 4b7c4cd7a11d -r e62fc9b3b09c dw.hpp --- a/dw.hpp Sun Dec 18 21:59:12 2022 +0000 +++ b/dw.hpp Mon Dec 19 00:07:06 2022 +0000 @@ -7,6 +7,13 @@ #define _HPP_DW #include +// Attempt to support compilers without nullptr type literal +#if __cplusplus >= 201103L +#define DW_NULL nullptr +#else +#define DW_NULL NULL +#endif + namespace DW { @@ -50,7 +57,7 @@ void PackAtIndex(Widget *item, int index, int width, int height, int hsize, int vsize, int pad) { dw_box_pack_at_index(hwnd, item ? item->GetHWND() : DW_NOHWND, index, width, height, hsize, vsize, pad); } Widget *UnpackAtIndex(int index) { HWND widget = dw_box_unpack_at_index(hwnd, index); - void *classptr = widget ? dw_window_get_data(widget, "_dw_classptr") : nullptr; + void *classptr = widget ? dw_window_get_data(widget, "_dw_classptr") : DW_NULL; return reinterpret_cast(classptr); } }; @@ -125,11 +132,11 @@ void operator=(const App &) = delete; #endif // Initialization functions for creating App - static App *Init() { if(!_app) { _app = new App; dw_init(TRUE, 0, NULL); } return _app; } - static App *Init(const char *appid) { if(!_app) { _app = new App(); dw_app_id_set(appid, NULL); dw_init(TRUE, 0, NULL); } return _app; } - static App *Init(const char *appid, const char *appname) { if(!_app) { _app = new App(); dw_app_id_set(appid, appname); dw_init(TRUE, 0, NULL); } return _app; } + static App *Init() { if(!_app) { _app = new App; dw_init(TRUE, 0, DW_NULL); } return _app; } + static App *Init(const char *appid) { if(!_app) { _app = new App(); dw_app_id_set(appid, DW_NULL); dw_init(TRUE, 0, DW_NULL); } return _app; } + static App *Init(const char *appid, const char *appname) { if(!_app) { _app = new App(); dw_app_id_set(appid, appname); dw_init(TRUE, 0, DW_NULL); } return _app; } static App *Init(int argc, char *argv[]) { if(!_app) { _app = new App(); dw_init(TRUE, argc, argv); } return _app; } - static App *Init(int argc, char *argv[], const char *appid) { if(!_app) { _app = new App(); dw_app_id_set(appid, NULL); dw_init(TRUE, argc, argv); } return _app; } + static App *Init(int argc, char *argv[], const char *appid) { if(!_app) { _app = new App(); dw_app_id_set(appid, DW_NULL); dw_init(TRUE, argc, argv); } return _app; } static App *Init(int argc, char *argv[], const char *appid, const char *appname) { if(!_app) { _app = new App(); dw_app_id_set(appid, appname); dw_init(TRUE, argc, argv); } return _app; } void Main() { dw_main(); } @@ -139,7 +146,7 @@ }; // Static singleton reference declared outside of the class -App* App::_app = nullptr; +App* App::_app = DW_NULL; #if 0 // Class that allows drawing, either to screen or picture (pixmap) diff -r 4b7c4cd7a11d -r e62fc9b3b09c makefile.vc --- a/makefile.vc Sun Dec 18 21:59:12 2022 +0000 +++ b/makefile.vc Mon Dec 19 00:07:06 2022 +0000 @@ -113,7 +113,7 @@ # These options will hide the deprecation warnings; Comment the next line to see them CRT_FLAGS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNING -D_WINSOCK_DEPRECATED_NO_WARNINGS -CFLAGS = -c $(PLATFORM_DEF) -D__WIN32__ -DMSVC -DRICHEDIT -DTOOLBAR -DGDIPLUS -DAEROGLASS -D_UNICODE -DUNICODE -DBUILD_DLL -DISOLATION_AWARE_ENABLED=1 -I$(SRCDIR)\platform -I$(SRCDIR) $(WEBVIEW2INC) $(WINTOASTINC) $(SVNVERSION) $(CRT_FLAGS) +CFLAGS = -c $(PLATFORM_DEF) -D__WIN32__ -DMSVC -DRICHEDIT -DTOOLBAR -DGDIPLUS -D_UNICODE -DUNICODE -DBUILD_DLL -DISOLATION_AWARE_ENABLED=1 -I$(SRCDIR)\platform -I$(SRCDIR) $(WEBVIEW2INC) $(WINTOASTINC) $(SVNVERSION) $(CRT_FLAGS) LIBS = wsock32.lib kernel32.lib user32.lib comctl32.lib gdi32.lib advapi32.lib shell32.lib comdlg32.lib ole32.lib oleaut32.lib userenv.lib msimg32.lib gdiplus.lib $(WEBVIEW2LIB) RES = LINKFLAGS = -machine:$(TARGET_CPU) -manifest $(LINK_DEBUG)