diff options
-rw-r--r-- | numpy/core/include/numpy/random/distributions.h | 8 | ||||
-rw-r--r-- | numpy/random/_examples/cffi/parse.py | 11 |
2 files changed, 18 insertions, 1 deletions
diff --git a/numpy/core/include/numpy/random/distributions.h b/numpy/core/include/numpy/random/distributions.h index c474c4d14..3ffacc8f9 100644 --- a/numpy/core/include/numpy/random/distributions.h +++ b/numpy/core/include/numpy/random/distributions.h @@ -1,6 +1,10 @@ #ifndef _RANDOMDGEN__DISTRIBUTIONS_H_ #define _RANDOMDGEN__DISTRIBUTIONS_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "Python.h" #include "numpy/npy_common.h" #include <stddef.h> @@ -197,4 +201,8 @@ static NPY_INLINE double next_double(bitgen_t *bitgen_state) { return bitgen_state->next_double(bitgen_state->state); } +#ifdef __cplusplus +} +#endif + #endif diff --git a/numpy/random/_examples/cffi/parse.py b/numpy/random/_examples/cffi/parse.py index 73d8646c7..daff6bdec 100644 --- a/numpy/random/_examples/cffi/parse.py +++ b/numpy/random/_examples/cffi/parse.py @@ -17,11 +17,20 @@ def parse_distributions_h(ffi, inc_dir): continue s.append(line) ffi.cdef('\n'.join(s)) - + with open(os.path.join(inc_dir, 'random', 'distributions.h')) as fid: s = [] in_skip = 0 + ignoring = False for line in fid: + # check for and remove extern "C" guards + if ignoring: + if line.strip().startswith('#endif'): + ignoring = False + continue + if line.strip().startswith('#ifdef __cplusplus'): + ignoring = True + # massage the include file if line.strip().startswith('#'): continue |