diff options
-rw-r--r-- | numpy/core/SConscript | 11 | ||||
-rw-r--r-- | numpy/core/include/numpy/ndarrayobject.h | 7 | ||||
-rw-r--r-- | numpy/core/include/numpy/numpyconfig.h.in | 2 | ||||
-rw-r--r-- | numpy/core/setup.py | 18 |
4 files changed, 37 insertions, 1 deletions
diff --git a/numpy/core/SConscript b/numpy/core/SConscript index ec9a78491..a2d5198d2 100644 --- a/numpy/core/SConscript +++ b/numpy/core/SConscript @@ -1,4 +1,4 @@ -# Last Change: Mon Jul 28 03:00 PM 2008 J +# Last Change: Tue Aug 05 12:00 PM 2008 J # vim:syntax=python import os import sys @@ -98,6 +98,15 @@ else: nosmp = 0 numpyconfig_sym.append(('NPY_NO_SMP', nosmp)) +#---------------------------------------------- +# Check whether we can use C99 printing formats +#---------------------------------------------- +if config.CheckDeclaration(('PRIdPTR'), includes = '#include <inttypes.h>'): + usec99 = 1 +else: + usec99 = 0 +numpyconfig_sym.append(('USE_C99_FORMATS', usec99)) + #---------------------- # Checking the mathlib #---------------------- diff --git a/numpy/core/include/numpy/ndarrayobject.h b/numpy/core/include/numpy/ndarrayobject.h index 837d8157f..ff22602cc 100644 --- a/numpy/core/include/numpy/ndarrayobject.h +++ b/numpy/core/include/numpy/ndarrayobject.h @@ -971,6 +971,13 @@ typedef Py_uintptr_t npy_uintp; #define NPY_INTP_FMT "Ld" #endif +/* We can only use C99 formats for npy_int_p if it is the same as intp_t, hence + * the condition on HAVE_UNITPTR_T */ +#if NPY_USE_C99_FORMATS == 1 && HAVE_UINTPRT_T + #undef NPY_INTP_FMT + #define NPY_INTP_FMT PRIdPTR +#endif + #define NPY_ERR(str) fprintf(stderr, #str); fflush(stderr); #define NPY_ERR2(str) fprintf(stderr, str); fflush(stderr); diff --git a/numpy/core/include/numpy/numpyconfig.h.in b/numpy/core/include/numpy/numpyconfig.h.in index 929dc720d..573c4f73e 100644 --- a/numpy/core/include/numpy/numpyconfig.h.in +++ b/numpy/core/include/numpy/numpyconfig.h.in @@ -14,3 +14,5 @@ @DEFINE_NPY_SIZEOF_LONGLONG@ @DEFINE_NPY_SIZEOF_PY_LONG_LONG@ + +#define NPY_USE_C99_FORMATS @USE_C99_FORMATS@ diff --git a/numpy/core/setup.py b/numpy/core/setup.py index f33322f4b..b390c8f91 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -189,6 +189,24 @@ def configuration(parent_package='',top_path=None): raise SystemError,"Failed to generate numpy configuration. "\ "See previous error messages for more information." + moredefs = [] + + # Check wether we can use inttypes (C99) formats + if config_cmd.check_decl('PRIdPTR', headers = ['inttypes.h']): + moredefs.append(('NPY_USE_C99_FORMATS', 1)) + else: + moredefs.append(('NPY_USE_C99_FORMATS', 0)) + + # Add moredefs to header + target_f = open(target,'a') + for d in moredefs: + if isinstance(d,str): + target_f.write('#define %s\n' % (d)) + else: + target_f.write('#define %s %s\n' % (d[0],d[1])) + target_f.close() + + # Dump the numpyconfig.h header to stdout print 'File: %s' % target target_f = open(target) print target_f.read() |