common.h: define ZINT_IS_C89 as __STDC_VERSION__ not defined by MSVC

zintconfig.h: edit generator file zintconfig.h.in
This commit is contained in:
gitlost 2022-09-14 14:48:57 +01:00
parent 102c2f3a69
commit d0cfabba84
5 changed files with 20 additions and 17 deletions

View File

@ -41,11 +41,16 @@ extern "C" {
#define ARRAY_SIZE(x) ((int) (sizeof(x) / sizeof((x)[0]))) #define ARRAY_SIZE(x) ((int) (sizeof(x) / sizeof((x)[0])))
#endif #endif
/* Determine if C89 (excluding MSVC, which doesn't define __STDC_VERSION__) */
#if !defined(_MSC_VER) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199000L)
#define ZINT_IS_C89
#endif
#ifdef _MSC_VER #ifdef _MSC_VER
# include <malloc.h> # include <malloc.h>
# define z_alloca(nmemb) _alloca(nmemb) # define z_alloca(nmemb) _alloca(nmemb)
#else #else
# if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199000L) || defined(__NuttX__) /* C89 or NuttX RTOS */ # if defined(ZINT_IS_C89) || defined(__NuttX__) /* C89 or NuttX RTOS */
# include <alloca.h> # include <alloca.h>
# endif # endif
# define z_alloca(nmemb) alloca(nmemb) # define z_alloca(nmemb) alloca(nmemb)
@ -101,14 +106,13 @@ typedef unsigned __int64 uint64_t;
#define ustrcat(target, source) strcat((char *) (target), (const char *) (source)) #define ustrcat(target, source) strcat((char *) (target), (const char *) (source))
#define ustrncat(target, source, count) strncat((char *) (target), (const char *) (source), (count)) #define ustrncat(target, source, count) strncat((char *) (target), (const char *) (source), (count))
/* VC6 or C89 */ #if (defined(_MSC_VER) && _MSC_VER == 1200) || defined(ZINT_IS_C89) /* VC6 or C89 */
#if (defined(_MSC_VER) && _MSC_VER == 1200) || (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199000L)
# define ceilf (float) ceil # define ceilf (float) ceil
# define floorf (float) floor # define floorf (float) floor
# define fmodf (float) fmod # define fmodf (float) fmod
#endif #endif
/* `round()` (C99) not before MSVC 2013 (C++ 12.0) */ /* `round()` (C99) not before MSVC 2013 (C++ 12.0) */
#if (defined(_MSC_VER) && _MSC_VER < 1800) || (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199000L) #if (defined(_MSC_VER) && _MSC_VER < 1800) || defined(ZINT_IS_C89)
# define round(arg) floor((arg) + 0.5) # define round(arg) floor((arg) + 0.5)
# define roundf(arg) floorf((arg) + 0.5f) # define roundf(arg) floorf((arg) + 0.5f)
#endif #endif

View File

@ -34,24 +34,22 @@
/* Due to above: */ /* Due to above: */
/* SPDX-License-Identifier: LGPL-2.1+ */ /* SPDX-License-Identifier: LGPL-2.1+ */
#include "testcommon.h"
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#include <direct.h> #include <direct.h>
#endif #endif
#include "../eci.h"
#ifndef NO_PNG #ifndef NO_PNG
#include <png.h> #include <png.h>
#include <zlib.h> #include <zlib.h>
#include <setjmp.h> #include <setjmp.h>
#endif #endif
#include <assert.h> #include <assert.h>
#include <errno.h>
#include <limits.h> #include <limits.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "testcommon.h"
#include "../eci.h"
static int tests = 0; static int tests = 0;
static int failed = 0; static int failed = 0;
static int skipped = 0; static int skipped = 0;
@ -63,7 +61,7 @@ static const char *testFunc = NULL;
/* Visual C++ 6 doesn't support variadic args to macros, so make do with functions, which have inferior behaviour, /* Visual C++ 6 doesn't support variadic args to macros, so make do with functions, which have inferior behaviour,
e.g. don't exit on failure, `assert_equal()` type-specific */ e.g. don't exit on failure, `assert_equal()` type-specific */
#if (defined(_MSC_VER) && _MSC_VER == 1200) || (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199000L) /* VC6 or C89 */ #if (defined(_MSC_VER) && _MSC_VER == 1200) || defined(ZINT_IS_C89) /* VC6 or C89 */
#include <stdarg.h> #include <stdarg.h>
void assert_zero(int exp, const char *fmt, ...) { void assert_zero(int exp, const char *fmt, ...) {
assertionNum++; assertionNum++;

View File

@ -57,7 +57,7 @@ extern "C" {
#define testutil_pclose(stream) _pclose(stream) #define testutil_pclose(stream) _pclose(stream)
#else #else
#include <unistd.h> #include <unistd.h>
# if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199000L /* C89 */ # if defined(ZINT_IS_C89)
extern FILE *popen(const char *command, const char *type); extern FILE *popen(const char *command, const char *type);
extern int pclose(FILE *stream); extern int pclose(FILE *stream);
# endif # endif
@ -101,7 +101,7 @@ typedef struct s_testFunction {
void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size); void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size);
int testContinue(const testCtx *const p_ctx, const int i); int testContinue(const testCtx *const p_ctx, const int i);
#if (defined(_MSC_VER) &&_MSC_VER == 1200) || (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199000L) /* VC6 or C89 */ #if (defined(_MSC_VER) &&_MSC_VER == 1200) || defined(ZINT_IS_C89) /* VC6 or C89 */
void assert_zero(int exp, const char *fmt, ...); void assert_zero(int exp, const char *fmt, ...);
void assert_nonzero(int exp, const char *fmt, ...); void assert_nonzero(int exp, const char *fmt, ...);
void assert_null(const void *exp, const char *fmt, ...); void assert_null(const void *exp, const char *fmt, ...);

View File

@ -1,4 +1,4 @@
/* zintconfig.h - the configured options and settings for libzint */ /* zintconfig.h - the configured options and settings for libzint, generated from "zintconfig.h.in" by CMake */
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com>

View File

@ -1,7 +1,7 @@
/* zintconfig.h - the configured options and settings for libzint /* zintconfig.h - the configured options and settings for libzint, generated from "zintconfig.h.in" by CMake */
/*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com> Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@ -28,7 +28,7 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE. SUCH DAMAGE.
*/ */
/* vim: set ts=4 sw=4 et : */ /* SPDX-License-Identifier: BSD-3-Clause */
#ifndef ZINTCONFIG_H #ifndef ZINTCONFIG_H
#define ZINTCONFIG_H #define ZINTCONFIG_H
@ -38,4 +38,5 @@
#define ZINT_VERSION_RELEASE @ZINT_VERSION_RELEASE@ #define ZINT_VERSION_RELEASE @ZINT_VERSION_RELEASE@
#define ZINT_VERSION_BUILD @ZINT_VERSION_BUILD@ #define ZINT_VERSION_BUILD @ZINT_VERSION_BUILD@
/* vim: set ts=4 sw=4 et : */
#endif /* ZINTCONFIG_H */ #endif /* ZINTCONFIG_H */