diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2022-04-21 19:36:38 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2022-04-21 19:36:38 +0000 |
commit | 2f4aaac54eca71f8c5735e06235ddb9610b465b0 (patch) | |
tree | 9c9a2a1c31ae299b83373d856d496d81059086d0 /include | |
parent | 7885dc0ac20062d6e7bb9aa2cc1d0197fcc865e0 (diff) | |
download | sg3_utils-2f4aaac54eca71f8c5735e06235ddb9610b465b0.tar.gz |
Merge pull request #16 from bvanassche/master
Enable continuous integration
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@947 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'include')
-rw-r--r-- | include/sg_pr2serr.h | 51 |
1 files changed, 11 insertions, 40 deletions
diff --git a/include/sg_pr2serr.h b/include/sg_pr2serr.h index afac7c09..8830f717 100644 --- a/include/sg_pr2serr.h +++ b/include/sg_pr2serr.h @@ -25,7 +25,7 @@ * assumes that cp[0] is the null character and does nothing (and returns * 0). Linux kernel has a similar function called scnprintf(). */ - +#include <inttypes.h> #include <stdio.h> #include <stdbool.h> @@ -65,50 +65,21 @@ typedef struct sg_json_state_t { } sg_json_state; -#if defined(__GNUC__) || defined(__clang__) -#ifdef SG_LIB_MINGW -/* MinGW uses Microsoft's printf */ -int pr2serr(const char * fmt, ...); - -int pr2ws(const char * fmt, ...); - -/* Want safer, 'n += snprintf(b + n, blen - n, ...)' style sequence of - * functions. Returns number of chars placed in cp excluding the trailing null - * char. So for cp_max_len > 0 the return value is always < cp_max_len; for - * cp_max_len <= 1 the return value is 0 and no chars are written to cp. Note - * this means that when cp_max_len = 1, this function assumes that cp[0] is - * the null character and does nothing (and returns 0). Linux kernel has a - * similar function called scnprintf(). */ -int sg_scnpr(char * cp, int cp_max_len, const char * fmt, ...); - -void sgj_pr_hr(sg_json_state * jsp, const char * fmt, ...); - -#else /* GNU/clang other than MinGW */ - -int pr2serr(const char * fmt, ...) - __attribute__ ((format (printf, 1, 2))); - -int pr2ws(const char * fmt, ...) - __attribute__ ((format (printf, 1, 2))); - -int sg_scnpr(char * cp, int cp_max_len, const char * fmt, ...) - __attribute__ ((format (printf, 3, 4))); - -void sgj_pr_hr(sg_json_state * jsp, const char * fmt, ...) - __attribute__ ((format (printf, 2, 3))); +#if __USE_MINGW_ANSI_STDIO -0 == 1 +#define __printf(a, b) __attribute__((__format__(gnu_printf, a, b))) +#elif defined(__GNUC__) || defined(__clang__) +#define __printf(a, b) __attribute__((__format__(printf, a, b))) +#else +#define __printf(a, b) #endif -#else /* not GNU (and not clang) */ +int pr2serr(const char * fmt, ...) __printf(1, 2); -int pr2serr(const char * fmt, ...); +int pr2ws(const char * fmt, ...) __printf(1, 2); -int pr2ws(const char * fmt, ...); +int sg_scnpr(char * cp, int cp_max_len, const char * fmt, ...) __printf(3, 4); -int sg_scnpr(char * cp, int cp_max_len, const char * fmt, ...); - -void sgj_pr_hr(sg_json_state * jsp, const char * fmt, ...); - -#endif +void sgj_pr_hr(sg_json_state * jsp, const char * fmt, ...) __printf(2, 3); void sg_json_init_state(sg_json_state * jstp); |