Commit 8a6aeb58 authored by Mathis Rosenhauer's avatar Mathis Rosenhauer

windows: support snprintf for older MSVC

parent e3d026ae
......@@ -3,6 +3,7 @@ set(CMAKE_C_STANDARD 99)
include(CheckIncludeFiles)
include(TestBigEndian)
include(CheckCSourceCompiles)
include(CheckSymbolExists)
include(cmake/macros.cmake)
project(libaec)
set(libaec_VERSION_MAJOR 1)
......@@ -21,6 +22,12 @@ endif(NOT HAVE_DECL___BUILTIN_CLZLL)
find_inline_keyword()
find_restrict_keyword()
check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
if(NOT HAVE_SNPRINTF)
check_symbol_exists(_snprintf "stdio.h" HAVE__SNPRINTF)
check_symbol_exists(_snprintf_s "stdio.h" HAVE__SNPRINTF_S)
endif(NOT HAVE_SNPRINTF)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)
......
......@@ -3,3 +3,6 @@
#cmakedefine WORDS_BIGENDIAN 1
#cmakedefine HAVE_DECL___BUILTIN_CLZLL 1
#cmakedefine HAVE_BSR64 1
#cmakedefine HAVE_SNPRINTF 1
#cmakedefine HAVE__SNPRINTF 1
#cmakedefine HAVE__SNPRINTF_S 1
......@@ -25,7 +25,7 @@ AC_TYPE_UINT8_T
AC_C_INLINE
AC_C_RESTRICT
AC_CHECK_FUNCS([memset strstr])
AC_CHECK_FUNCS([memset strstr snprintf])
AC_CHECK_DECLS(__builtin_clzll)
AM_EXTRA_RECURSIVE_TARGETS([bench benc bdec])
......
#ifndef CHECK_AEC_H
#define CHECK_AEC_H 1
#include <config.h>
#include "libaec.h"
struct test_state {
......@@ -24,6 +26,18 @@ int update_state(struct test_state *state);
int encode_decode_small(struct test_state *state);
int encode_decode_large(struct test_state *state);
#ifndef HAVE_SNPRINTF
#ifdef HAVE__SNPRINTF_S
#define snprintf(d, n, ...) _snprintf_s((d), (n), _TRUNCATE, __VA_ARGS__)
#else
#ifdef HAVE__SNPRINTF
#define snprintf _snprintf
#else
#error "no snprintf compatible function found"
#endif /* HAVE__SNPRINTF */
#endif /* HAVE__SNPRINTF_S */
#endif /* HAVE_SNPRINTF */
#ifdef _WIN32
#define CHECK_PASS "PASS"
#define CHECK_FAIL "FAIL"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment