autoconf: Check for ll hh j z t size specifiers introduced by C99
Add custom test for checking whether formatted IO functions (printf/scanf et.al.) support 'size specifiers' introduced by C99, namely ll, hh, j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t). Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jakub Narebski committed
Aug 4, 2006 at 17:55 UTC
656517b9ef5cf443f72110dcd56b15825bc7f1ef
1 file changed
+21
configure.ac
+21
@@ -189,6 +189,27 @@ AC_CHECK_MEMBER(struct dirent.d_type,[],
189
AC_CHECK_TYPE(struct sockaddr_storage,[],
190
[GIT_CONF_APPEND_LINE(NO_SOCKADDR_STORAGE=YesPlease)],
191
[#include <netinet/in.h>])
192
+#
193
+# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
194
+# do not support the 'size specifiers' introduced by C99, namely ll, hh,
195
+# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
196
+# some C compilers supported these specifiers prior to C99 as an extension.
197
+AC_CACHE_CHECK(whether IO functions support %ll %hh %j %z %t size specifiers,
198
+ ac_cv_c_c99_format,
199
+[# Actually git uses only %z (%zu) in alloc.c, and %t (%td) in mktag.c
200
+AC_RUN_IFELSE(
201
+ [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
202
+ [[char buf[64];
203
+ if (sprintf(buf, "%lld%hhd%jd%zd%td", (long long int)1, (char)2, (intmax_t)3, (size_t)4, (ptrdiff_t)5) != 5)
204
+ exit(1);
205
+ else if (strcmp(buf, "12345"))
206
+ exit(2);]])],
207
+ [ac_cv_c_c99_format=yes],
208
+ [ac_cv_c_c99_format=no])
209
+])
210
+if test $ac_cv_c_c99_format = no; then
211
+ GIT_CONF_APPEND_LINE(NO_C99_FORMAT=YesPlease)
212
+fi
213
214
215
## Checks for library functions.