]> granicus.if.org Git - python/commitdiff
Detect if %zd is supported by printf() during configure and sets
authorBrett Cannon <bcannon@gmail.com>
Thu, 11 May 2006 05:11:33 +0000 (05:11 +0000)
committerBrett Cannon <bcannon@gmail.com>
Thu, 11 May 2006 05:11:33 +0000 (05:11 +0000)
PY_FORMAT_SIZE_T appropriately.  Removes warnings on
OS X under gcc 4.0.1 when PY_FORMAT_SIZE_T is set to "" instead of "z" as is
needed.

configure
configure.in
pyconfig.h.in

index e05fad610442fb465cd97ebb7a6f95dbd3f21609..6297d9f1c660db089d7c8814c224c138259d50ff 100755 (executable)
--- a/configure
+++ b/configure
@@ -21732,6 +21732,68 @@ else
 echo "${ECHO_T}no" >&6
 fi
 
+echo "$as_me:$LINENO: checking for %zd printf() format support" >&5
+echo $ECHO_N "checking for %zd printf() format support... $ECHO_C" >&6
+if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+
+int main()
+{
+    char buffer[4];
+
+    if(sprintf(buffer, "%zd", (size_t)123) < 0)
+               return 1;
+
+    if (strncmp(buffer, "123", 3))
+       return 1;
+
+    return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define PY_FORMAT_SIZE_T "z"
+_ACEOF
+
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
 echo "$as_me:$LINENO: checking for socklen_t" >&5
 echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6
 if test "${ac_cv_type_socklen_t+set}" = set; then
index e2dae9d4843840e05ef40a3be414db198d2a1563..168c621aeb7aec348bdfa85b5d276f478abf1a9e 100644 (file)
@@ -3247,6 +3247,27 @@ else
   AC_MSG_RESULT(no)
 fi
 
+AC_MSG_CHECKING(for %zd printf() format support)
+AC_TRY_RUN([#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+
+int main()
+{
+    char buffer[4];
+
+    if(sprintf(buffer, "%zd", (size_t)123) < 0)
+               return 1;
+
+    if (strncmp(buffer, "123", 3))
+       return 1;
+    
+    return 0;
+}],
+[AC_MSG_RESULT(yes)
+ AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
+ AC_MSG_RESULT(no))
+
 AC_CHECK_TYPE(socklen_t,,
   AC_DEFINE(socklen_t,int,
             Define to `int' if <sys/socket.h> does not define.),[
index 886b3368660d751dfc904f1eb7e3f249063fd733..acbbd8d23f99068a8687402e3e60d9b8bea9364d 100644 (file)
 /* Defined if PTHREAD_SCOPE_SYSTEM supported. */
 #undef PTHREAD_SYSTEM_SCHED_SUPPORTED
 
+/* Define to printf format modifier for Py_ssize_t */
+#undef PY_FORMAT_SIZE_T
+
 /* Define as the integral type used for Unicode representation. */
 #undef PY_UNICODE_TYPE