Repository navigation
BUG: avoid side-effect of 'include complex.h' - #26789
Conversation
rgommers
left a comment
There was a problem hiding this comment.
LGTM. In this case it fixes a regression for SymPy, but even without that it seems like a reasonable thing to do since I isn't a great name to propagate to users of numpy headers.
|
I wonder if we could add a test for this in the |
|
Seems reasonable to add a test, probably requires only including a numpy header and then defining a variable |
Makes sense |
|
Wouldn't this break existing uses of How about adding this to our That is especially for a backport. |
|
Ah, sorry, I had read Cython in the title but I guess it is just as much about C code there. Still seems a bit like we might break code that already uses But, I don't have a big opinion either way, because I don't really know how likely it is we will regress others, since there seems to be no choice that regresses nobody. |
|
I think the error this way is preferred to the (current) opposite. If we undefine |
|
Any more review needed here? |
|
No, if people notice, we may want to add docs on how to re-add Thanks @mattip. |
not sure if this belongs in a new ticket, but I noticed: This is from a C extension module that has |
That's a bug in that code I'm afraid. The numpy headers will use This is a very common bug, that only occasionally gives rise to issues (and if so, often on niche platforms/configs, like Cygwin). I'll note that SciPy has a script that's run in CI to catch the problem that may come in handy: https://github.com/scipy/scipy/blob/main/tools/check_python_h_first.py |
|
@rgommers, thanks for following up. The header block for the relevant module looks like this: #include <Python.h>
/* standard includes */
#include <stdio.h>
#include <math.h>
#include <complex.h>
#include <string.h>
/* LAL Includes */
#include <lal/LALDatatypes.h>
#include <lal/LALStdlib.h>
#include <lal/Units.h>
#include <lal/LALInspiral.h>
/* GSL includes */
#include <gsl/gsl_complex.h>
#include <gsl/gsl_complex_math.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_blas.h>
#include <numpy/arrayobject.h>As far as I can tell that follows your requirements, but ends up with |
|
This is due to issue #26787 and this PR. I am not sure what the correct path forward is, unfortunately C does not have namespaces (even though they are a honking great idea). |
|
Ah yes, that does meet the requirement, so no bug then indeed.
Somebody noticed .... no way to win here really. |
|
@duncanmmacleod please open a new issue, and link to the code in question. |
|
Hi, GCC dev here. This PR is just completely wrong. It's one thing to insist that users must include Just saying users can include Public library headers should not be doing this. |
|
@jwakely FWIW, we already reverted the undef. |
|
Yeah, I'm aware it was already reverted by #27182 I just wanted to very clearly make the point that this was never OK in the first place. You can mess with the contents of standard library headers inside a |
|
As long as we have the ear of a GCC dev, |
GCC doesn't get to just not define something that's in the C standard and whatever. By all means take that up with the C standard, but GCC has no choice. And you're 25+ years too late to take it up with the C standard now anyway, since it was added for C99. |
|
Defining it for C++ (rather than only for C) is a GCC choice, not something required by the C++ standard. But is only done for |
Fixes #26787
I confirmed the example in the issue fails before, passes after this fix.