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

lists.c:67: error: ‘SIZE_MAX’ undeclared #361

Closed
noloader opened this issue Mar 25, 2021 · 3 comments
Closed

lists.c:67: error: ‘SIZE_MAX’ undeclared #361

noloader opened this issue Mar 25, 2021 · 3 comments

Comments

@noloader
Copy link

noloader commented Mar 25, 2021

I'm building on older Apple hardware. It is an old PowerMac with OS X 10.5. P11-Kit 0.23.22 is having trouble in lists.c:

$ make V=1 2>&1 | fold -w80
make  all-recursive
Making all in .
depbase=`echo p11-kit/lists.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
        /usr/bin/cc -DHAVE_CONFIG_H -I.  -I. -I./common -DBINDIR=\"/usr/local/bi
n\" -DBUILDDIR=\"/Users/jwalton/Build-Scripts/p11-kit-0.23.22\" -DDATA_DIR=\"/us
r/local/share\" -DPRIVATEDIR=\"/usr/local/libexec/p11-kit\" -DSRCDIR=\"/Users/jw
alton/Build-Scripts/p11-kit-0.23.22\" -DSYSCONFDIR=\"/usr/local/etc\" -DP11_KIT_
FUTURE_UNSTABLE_API -I/usr/local/include -DNDEBUG  -g2 -O2 -mlong-double-64 -fno
-common -maltivec -fPIC -pthread -g             -Wall -Wstrict-prototypes -Wmiss
ing-declarations                -Wmissing-prototypes -Wnested-externs -Wpointer-
arith           -Wdeclaration-after-statement -Wformat=2 -Winit-self
-Waggregate-return -Wno-missing-format-attribute                -fno-strict-alia
sing -fno-common -Wmissing-include-dirs -Wundef -MT p11-kit/lists.o -MD -MP -MF
$depbase.Tpo -c -o p11-kit/lists.o p11-kit/lists.c &&\
        mv -f $depbase.Tpo $depbase.Po
p11-kit/lists.c: In function 'hex_encode':
p11-kit/lists.c:67: error: 'SIZE_MAX' undeclared (first use in this function)
p11-kit/lists.c:67: error: (Each undeclared identifier is reported only once
p11-kit/lists.c:67: error: for each function it appears in.)
make[2]: *** [p11-kit/lists.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

This appears to allow the compile to continue. I'm not sure what damage it may cause later, though :)

--- p11-kit/lists.c
+++ p11-kit/lists.c
@@ -43,12 +43,21 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <limits.h>

 #include "message.h"
 #include "p11-kit.h"
 #include "tool.h"
 #include "uri.h"

+#ifndef SIZE_MAX
+# ifdef SIZE_T_MAX
+#  define SIZE_MAX SIZE_T_MAX
+# else
+#  define SIZE_MAX MAX_SIZE
+# endif
+#endif
+
 int p11_kit_list_modules (int argc,
                           char *argv[]);

The self tests run OK, so I'm guessing the damage is not too bad.

============================================================================
Testsuite summary for p11-kit 0.23.22
============================================================================
# TOTAL: 762
# PASS:  761
# SKIP:  1
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
============================================================================
@ueno
Copy link
Member

ueno commented Mar 25, 2021

Good catch, thanks! Is the second chunk really needed? I see SIZE_MAX is already used in other files (e.g., common/array.c) without that fallback definition.

@noloader
Copy link
Author

noloader commented Mar 25, 2021

Is the second chunk really needed?

Probably not. Yank it.

That's interesting the other files did not have troubles with SIZE_MAX. I wonder what is different about lists.c.

ueno added a commit to ueno/p11-kit that referenced this issue Mar 27, 2021
ueno added a commit that referenced this issue Mar 27, 2021
@ueno
Copy link
Member

ueno commented Mar 27, 2021

I've added the fix (without the fallback definition) in #362; if it doesn't work, please feel free to reopen.

@ueno ueno closed this as completed Mar 27, 2021
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