Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIZE_T_MAX redefined from limits.h #351

Closed
lhunath opened this issue Aug 11, 2017 · 1 comment
Closed

SIZE_T_MAX redefined from limits.h #351

lhunath opened this issue Aug 11, 2017 · 1 comment

Comments

@lhunath
Copy link

lhunath commented Aug 11, 2017

arraylist.c includes limits.h which when building for iOS/ARM, already defines SIZE_T_MAX:

#if !defined(_ANSI_SOURCE)
#ifdef __LP64__
#define LONG_BIT        64
#else /* !__LP64__ */
#define LONG_BIT        32
#endif /* __LP64__ */
#define SSIZE_MAX       LONG_MAX        /* max value for a ssize_t */
#define WORD_BIT        32

#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE)
#define SIZE_T_MAX      ULONG_MAX       /* max value for a size_t */

#define UQUAD_MAX       ULLONG_MAX
#define QUAD_MAX        LLONG_MAX
#define QUAD_MIN        LLONG_MIN

#endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE */
#endif /* !_ANSI_SOURCE */

The result is the following build error, when building for the iOS SDK:

  CC       arraylist.lo
  CC       debug.lo
  CC       json_c_version.lo
arraylist.c:26:9: error: 'SIZE_T_MAX' macro redefined [-Werror,-Wmacro-redefined]
#define SIZE_T_MAX UINT_MAX
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk/usr/include/arm/limits.h:101:9: note: previous definition is here
#define SIZE_T_MAX      ULONG_MAX       /* max value for a size_t */
        ^
1 error generated.
make[1]: *** [arraylist.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [install-recursive] Error 1
@lhunath
Copy link
Author

lhunath commented Aug 11, 2017

I believe this is an accurate fix:

diff --git arraylist.c arraylist.c
index 8439cc2..ddeb8d4 100644
--- arraylist.c
+++ arraylist.c
@@ -22,6 +22,7 @@
 # include <strings.h>
 #endif /* HAVE_STRINGS_H */

+#ifndef SIZE_T_MAX
 #if SIZEOF_SIZE_T == SIZEOF_INT
 #define SIZE_T_MAX UINT_MAX
 #elif SIZEOF_SIZE_T == SIZEOF_LONG
@@ -31,6 +32,7 @@
 #else
 #error Unable to determine size of size_t
 #endif
+#endif

 #include "arraylist.h"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants