build: sync default CXXFLAGS and DEFINES with ndn-cxx

Change-Id: I0dc7928eaacd979736be40dcc71e712bf8f5f0f9
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index 4e09a82..ef97f25 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -136,7 +136,7 @@
 
     def getDebugFlags(self, conf):
         """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode"""
-        return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['_DEBUG']}
+        return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
 
     def getOptimizedFlags(self, conf):
         """Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode"""
@@ -174,6 +174,9 @@
             '-Wno-error=maybe-uninitialized', # Bug #1615
         ]
         flags['LINKFLAGS'] += self.__linkFlags
+        # Enable assertions in libstdc++
+        # https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html
+        flags['DEFINES'] += ['_GLIBCXX_ASSERTIONS=1']
         return flags
 
     def getOptimizedFlags(self, conf):
@@ -222,6 +225,9 @@
         elif Utils.unversioned_sys_platform() == 'freebsd':
             # Bug #4790
             flags['CXXFLAGS'] += [['-isystem', '/usr/local/include']]
+        if self.getCompilerVersion(conf) >= (18, 0, 0):
+            # Bug #5300
+            flags['CXXFLAGS'] += ['-Wno-enum-constexpr-conversion']
         return flags
 
     __cxxFlags = [
@@ -232,6 +238,13 @@
     def getDebugFlags(self, conf):
         flags = super().getDebugFlags(conf)
         flags['CXXFLAGS'] += self.__cxxFlags
+        # Enable assertions in libc++
+        if self.getCompilerVersion(conf) >= (18, 0, 0):
+            # https://libcxx.llvm.org/Hardening.html
+            flags['DEFINES'] += ['_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE']
+        elif self.getCompilerVersion(conf) >= (15, 0, 0):
+            # https://releases.llvm.org/15.0.0/projects/libcxx/docs/UsingLibcxx.html#enabling-the-safe-libc-mode
+            flags['DEFINES'] += ['_LIBCPP_ENABLE_ASSERTIONS=1']
         return flags
 
     def getOptimizedFlags(self, conf):