tests/cxx: Do not assume that NULL is a pointer type starting with C++11

Many toolchain did not change the definition of NULL to avoid introducing
breaking changes in existing codebases. For example, on Windows NULL is
0 (int) regardless of the C++ standard in use.

Fixes the following warnings on CLang when compiling for Windows:

  ../glib/glib/tests/cxx.cpp:539:34: warning: missing sentinel in function call [-Wsentinel]
    g_test_init (&argc, &argv, NULL);
                                   ^
                                   , nullptr
  ../glib/glib/gtestutils.h:298:9: note: function has been explicitly marked sentinel here
  void    g_test_init                     (int            *argc,
          ^

  ../glib/gio/tests/cxx.cpp:62:34: warning: missing sentinel in function call [-Wsentinel]
    g_test_init (&argc, &argv, NULL);
                                   ^
                                   , nullptr
  ../glib/glib/gtestutils.h:298:9: note: function has been explicitly marked sentinel here
  void    g_test_init                     (int            *argc,
          ^
This commit is contained in:
Luca Bacci 2023-10-12 10:29:18 +02:00
parent 107311afce
commit 8264b13737
2 changed files with 2 additions and 2 deletions

View File

@ -59,7 +59,7 @@ int
main (int argc, char **argv)
{
#if G_CXX_STD_CHECK_VERSION (11)
g_test_init (&argc, &argv, NULL);
g_test_init (&argc, &argv, nullptr);
#else
g_test_init (&argc, &argv, static_cast<void *>(NULL));
#endif

View File

@ -536,7 +536,7 @@ int
main (int argc, char *argv[])
{
#if G_CXX_STD_CHECK_VERSION (11)
g_test_init (&argc, &argv, NULL);
g_test_init (&argc, &argv, nullptr);
#else
g_test_init (&argc, &argv, static_cast<void *>(NULL));
#endif