CMake: Check if vsnprinf() is C99-compliant

This commit is contained in:
João Valverde 2021-09-21 18:54:55 +01:00 committed by Wireshark GitLab Utility
parent a2120e823c
commit 5de2b55663
1 changed files with 25 additions and 1 deletions

View File

@ -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.