aboutsummaryrefslogtreecommitdiffstats
path: root/ConfigureChecks.cmake
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2021-09-21 18:54:55 +0100
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-09-22 12:10:27 +0000
commit5de2b5566356f8b2d41ed5a6b0f93c41d33cd2db (patch)
treedafb2f4becea180a2bfc5a4596c3e52674e7c731 /ConfigureChecks.cmake
parenta2120e823c7274d9c4301a27f3805c877ae9ff65 (diff)
CMake: Check if vsnprinf() is C99-compliant
Diffstat (limited to 'ConfigureChecks.cmake')
-rw-r--r--ConfigureChecks.cmake26
1 files changed, 25 insertions, 1 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 1b8d28a695..328292e699 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -103,7 +103,31 @@ check_struct_has_member("struct tm" tm_zone time.h HAVE_STRUC
#Symbols but NOT enums or types
check_symbol_exists(tzname "time.h" HAVE_TZNAME)
-# Check for stuff that isn't testable via the tests above
+#
+# Check if the libc vsnprintf() conforms to C99. If this fails we may
+# need to fall-back on GLib I/O.
+#
+check_c_source_runs("
+ #include <stdio.h>
+ int main(void)
+ {
+ /* Check that snprintf() and vsnprintf() don't return
+ * -1 if the buffer is too small. C99 says this value
+ * is the length that would be written not including
+ * the nul byte. */
+ char buf[3];
+ return snprintf(buf, sizeof(buf), \"%s\", \"ABCDEF\") > 0 ? 0 : 1;
+ }"
+ HAVE_C99_VSNPRINTF
+)
+if (NOT HAVE_C99_VSNPRINTF)
+ message(FATAL_ERROR
+"Building Wireshark requires a C99 compliant vsnprintf() and this \
+target does not meet that requirement. Compiling for ${CMAKE_SYSTEM} \
+using ${CMAKE_C_COMPILER_ID}. Please report this issue to the Wireshark \
+developers at wireshark-dev@wireshark.org."
+ )
+endif()
#
# *If* we found libnl, check if we can use nl80211 stuff with it.