Skip to content

Commit

Permalink
Use inttypes.h and stdint.h where appropriate (fixes 920)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Oct 17, 2023
1 parent c0d64ad commit e3c2b83
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

2023-10-17 David Declerck <[email protected]>

* configure.ac: add checks to allow using stdint.h and inttypes.h

2023-07-28 Simon Sobisch <[email protected]>

* configure.ac: check for mousemask and mmask_t
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ dnl AC_CHECK_HEADERS([stdint.h whcar.h malloc.h])
AC_CHECK_HEADERS([sys/types.h signal.h stddef.h], [],
[AC_MSG_ERROR([mandatory header could not be found or included])])
# optional:
AC_CHECK_HEADERS([sys/time.h locale.h fcntl.h dlfcn.h])
AC_CHECK_HEADERS([sys/time.h locale.h fcntl.h dlfcn.h stdint.h inttypes.h])


# Checks for typedefs, structures, and compiler characteristics.
Expand Down
5 changes: 5 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

2023-10-17 David Declerck <[email protected]>

* common.h: use stdint.h and inttypes.h when available to
define cob_s64_t, cob_u64_t and the various CB_FMT_ macros

2023-07-28 Simon Sobisch <[email protected]>

* screenio.c, common.c: replace use of NCURSES_MOUSE_VERSION by
Expand Down
26 changes: 24 additions & 2 deletions libcob/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,17 @@ typedef __mpz_struct mpz_t[1];
#define cob_sli_t long int
#define cob_uli_t unsigned long int

#if defined(_WIN32) && !defined(__MINGW32__)
#ifdef HAVE_STDINT_H

#include <stdint.h>

#define cob_s64_t int64_t
#define cob_u64_t uint64_t

#define COB_S64_C(x) x ## LL
#define COB_U64_C(x) x ## ULL

#elif defined(_WIN32) && !defined(__MINGW32__)

#define cob_s64_t __int64
#define cob_u64_t unsigned __int64
Expand All @@ -63,7 +73,19 @@ typedef __mpz_struct mpz_t[1];

#endif

#if defined(_WIN32)
#ifdef HAVE_INTTYPES_H

#include <inttypes.h>

#define CB_FMT_LLD "%"PRId64
#define CB_FMT_LLU "%"PRIu64
#define CB_FMT_LLX "%"PRIx64
#define CB_FMT_PLLD "%+*.*"PRId64
#define CB_FMT_PLLU "%*.*"PRIu64
#define CB_FMT_LLD_F "%"PRId64"LL"
#define CB_FMT_LLU_F "%"PRIu64"ULL"

#elif defined(_WIN32)

#define CB_FMT_LLD "%I64d"
#define CB_FMT_LLU "%I64u"
Expand Down

0 comments on commit e3c2b83

Please sign in to comment.