Index: Include/pyport.h =================================================================== --- Include/pyport.h (revision 67444) +++ Include/pyport.h (working copy) @@ -137,6 +137,20 @@ # error "Python doesn't support sizeof(pid_t) > sizeof(long)" #endif +/* + * Hide GCC's format attribute from compilers if one of the following is true: + * a) the compiler does not support it and not on RISC OS + * b) the compiler does not support "z" printf format specifier + */ +#if ((!defined(__GNUC__) || __GNUC__ < 2 || \ + (__GNUC__ == 2 && __GNUC_MINOR__ < 3)) && \ + !defined(RISCOS)) || \ + !defined(PY_FORMAT_SIZE_T) +#define Py_GCC_FORMAT_ATTRIBUTE(type, str_idx, arg_idx) +#else +#define Py_GCC_FORMAT_ATTRIBUTE(type, str_idx, arg_idx) __attribute__((format(type, str_idx, arg_idx))) +#endif + /* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf * format to convert an argument with the width of a size_t or Py_ssize_t. * C99 introduced "z" for this purpose, but not all platforms support that; @@ -690,17 +704,6 @@ #endif /* - * Hide GCC attributes from compilers that don't support them. - */ -#if (!defined(__GNUC__) || __GNUC__ < 2 || \ - (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ) && \ - !defined(RISCOS) -#define Py_GCC_ATTRIBUTE(x) -#else -#define Py_GCC_ATTRIBUTE(x) __attribute__(x) -#endif - -/* * Add PyArg_ParseTuple format where available. */ #ifdef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE Index: Include/stringobject.h =================================================================== --- Include/stringobject.h (revision 67444) +++ Include/stringobject.h (working copy) @@ -62,9 +62,9 @@ PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t); PyAPI_FUNC(PyObject *) PyString_FromString(const char *); PyAPI_FUNC(PyObject *) PyString_FromFormatV(const char*, va_list) - Py_GCC_ATTRIBUTE((format(printf, 1, 0))); + Py_GCC_FORMAT_ATTRIBUTE(printf, 1, 0); PyAPI_FUNC(PyObject *) PyString_FromFormat(const char*, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); + Py_GCC_FORMAT_ATTRIBUTE(printf, 1, 2); PyAPI_FUNC(Py_ssize_t) PyString_Size(PyObject *); PyAPI_FUNC(char *) PyString_AsString(PyObject *); PyAPI_FUNC(PyObject *) PyString_Repr(PyObject *, int); Index: Include/pgenheaders.h =================================================================== --- Include/pgenheaders.h (revision 67444) +++ Include/pgenheaders.h (working copy) @@ -10,9 +10,9 @@ #include "Python.h" PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); + Py_GCC_FORMAT_ATTRIBUTE(printf, 1, 2); PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); + Py_GCC_FORMAT_ATTRIBUTE(printf, 1, 2); #define addarc _Py_addarc #define addbit _Py_addbit Index: Include/sysmodule.h =================================================================== --- Include/sysmodule.h (revision 67444) +++ Include/sysmodule.h (working copy) @@ -14,9 +14,9 @@ PyAPI_FUNC(void) PySys_SetPath(char *); PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); + Py_GCC_FORMAT_ATTRIBUTE(printf, 1, 2); PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 1, 2))); + Py_GCC_FORMAT_ATTRIBUTE(printf, 1, 2); PyAPI_DATA(PyObject *) _PySys_TraceFunc, *_PySys_ProfileFunc; PyAPI_DATA(int) _PySys_CheckInterval; Index: Include/pyerrors.h =================================================================== --- Include/pyerrors.h (revision 67444) +++ Include/pyerrors.h (working copy) @@ -192,7 +192,7 @@ #endif /* Py_WIN_WIDE_FILENAMES */ PyAPI_FUNC(PyObject *) PyErr_Format(PyObject *, const char *, ...) - Py_GCC_ATTRIBUTE((format(printf, 2, 3))); + Py_GCC_FORMAT_ATTRIBUTE(printf, 2, 3); #ifdef MS_WINDOWS PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenameObject( @@ -319,9 +319,9 @@ #include PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...) - Py_GCC_ATTRIBUTE((format(printf, 3, 4))); + Py_GCC_FORMAT_ATTRIBUTE(printf, 3, 4); PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) - Py_GCC_ATTRIBUTE((format(printf, 3, 0))); + Py_GCC_FORMAT_ATTRIBUTE(printf, 3, 0); #ifdef __cplusplus }