]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use a proper compiler test for constexpr support
authorAydın Mercan <aydin@isc.org>
Mon, 28 Jul 2025 13:19:41 +0000 (13:19 +0000)
committerAydın Mercan <aydin@isc.org>
Tue, 19 Aug 2025 13:02:32 +0000 (16:02 +0300)
After GCC 15, C23 became the default version. [1]

Add a proper compiler test for constexpr support to ensure that GCC 15+
invoked with `c_std` set to `none` does not erroneously use the
constexpr shim.

This change does not affect the build in its default configuration
(which uses GNU C11); it is only meant to prepare the build system for
adding C23 elements to the code.

[1]: https://gcc.gnu.org/gcc-15/changes.html

meson.build

index 25e5388e7eabc797af864a3e1cf6b8df9d18c6f1..a2377345f6e31f19827c99dc76000ab6f31fdd79 100644 (file)
@@ -293,9 +293,14 @@ config.set_quoted('NAMED_CONFFILE', sysconfdir / 'named.conf')
 config.set_quoted('CACHEDB_DEFAULT', get_option('cachedb'))
 config.set_quoted('ZONEDB_DEFAULT', get_option('zonedb'))
 
-# Shim constexpr for pre-C23
-# "ne" => "none"
-if c_std.substring(-2) in ['ne', '89', '99', '11', '17', '18']
+constexpr_test = '''
+static constexpr int r = 0;
+
+int main(void) {
+    return r;
+}
+'''
+if not cc.compiles(constexpr_test, name: 'usage of constexpr')
     config.set('constexpr', 'static const')
 endif