Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix macOS compile with newer clang #221

Merged
merged 2 commits into from
Nov 13, 2023
Merged

Conversation

dopplershift
Copy link
Contributor

@dopplershift dopplershift commented Oct 24, 2023

This fixes up a compiler error seen on conda-forge with >=v15 of the Mac compilers, stemming from:

 src/pygrib/_pygrib.c:44829:3: error: incompatible pointer to integer conversion returning 'void *' from a function with result type 'int' [-Wint-conversion]
    import_array();
    ^~~~~~~~~~~~~~
  /Users/runner/miniforge3/conda-bld/pygrib_1698064180141/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.10/site-packages/numpy/core/include/numpy/__multiarray_api.h:1545:151: note: expanded from macro 'import_array'
  #define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NULL; } }
                                                                                                                                                        ^~~~
  /Users/runner/miniforge3/conda-bld/pygrib_1698064180141/_build_env/lib/clang/16/include/stddef.h:89:16: note: expanded from macro 'NULL'
  #  define NULL ((void*)0)
                 ^~~~~~~~~~

I see this building git locally, but only as a warning. Regardless, it seems easier to just call the Python function in the API instead of the macro.

I also fixed up some const warnings, including updating a few function devs from upstream.

This uses the Python version and avoids picking up a problematic macro
that fails compiling with clang >= 15 on conda-forge due to strictness.
(The compiler complains about returning NULL from a function declared to
return int.)

Also remove an unused cdef of PyArray_SIZE().
Updates to functions from grib_api.h reflect current version and date
back to 2012.
@dopplershift
Copy link
Contributor Author

Ok, this time the build worked properly. (ping @jswhit)

@jswhit jswhit merged commit 8dd6b9d into jswhit:master Nov 13, 2023
22 checks passed
@dopplershift dopplershift deleted the fix-compile branch November 13, 2023 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants