Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork12.1k
Comments
Conversation
The Python headers use this as, e.g.:PyAPI_FUNC(int) _PyTime_FromTimespec(_PyTime_t *tp, struct timespec *ts);When GCC sees this, it complains that the definition of `timespec`will not be visible outside of the function declaration. However,`timespec` is defined in `time.h`.Forward definition is the fix pipewire applied(https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/230).
seberg commentedNov 19, 2022
Seems a bit weird that this is necessary, found this (closed) Python issuepython/cpython#70040. But if that is needed for the warning 🤷 (maybe a comment that it is just to silence a warning on some setups?)... |
mattip commentedNov 20, 2022
On which platforms/compilations are you seeing the warning? |
stefanv commentedNov 20, 2022
This is on Linux (Fedora) compiling the meson branch. |
mattip commentedNov 21, 2022
That function is defined in Perhaps in Fedora the upstream code is modified? |
stefanv commentedNov 21, 2022
Looking at the Fedora sources for Python 3.10, I see the same. Here is the section of #ifdefTIME_WITH_SYS_TIME#include<sys/time.h>#include<time.h>#else/* !TIME_WITH_SYS_TIME */#ifdefHAVE_SYS_TIME_H#include<sys/time.h>#else/* !HAVE_SYS_TIME_H */#include<time.h>#endif/* !HAVE_SYS_TIME_H */#endif/* !TIME_WITH_SYS_TIME */ However, I can't find a good reference on when |
stefanv commentedNov 21, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
|
mattip commentedNov 23, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Here isthe current HEAD CPython version of the code you pointed to: This was simplified from the code you pointed to in CPython PRpython/cpython#29441 without a comment, seemingly to adapt to a change in autoconf. Edit: the change was applied to CPython3.11+ but was not backported. |
stefanv commentedNov 23, 2022
Thisalso appears on CI with Python 3.11. |
stefanv commentedNov 23, 2022
OK, I think I figured it out. #if defined__USE_POSIX199309|| defined__USE_ISOC11# include<bits/types/struct_timespec.h>#endif The following patches would make the warning go away, but I'm not sure if we're willing to jump to C11: diff --git a/meson.build b/meson.buildindex 775d59688..3784fe7b0 100644--- a/meson.build+++ b/meson.build@@ -9,7 +9,7 @@ project( meson_version: '>= 0.64.0', default_options: [ 'buildtype=debugoptimized',- 'c_std=c99',+ 'c_std=c11', 'cpp_std=c++11', 'blas=openblas', 'lapack=openblas', Alternatively, setting # define_XOPEN_SOURCE700# define_POSIX_C_SOURCE200809L#if defined_POSIX_C_SOURCE&& (_POSIX_C_SOURCE-0) >=199309L# define__USE_POSIX1993091#endif While investigating, I came uponthis S/O answer that explains it all nicely. |
rgommers commentedNov 24, 2022
Thanks@stefanv! Defining Jumping to C11 should be relatively safe by now, but it's hard to be sure on niche platforms. This would be less of a problem if we left |
mattip commentedNov 24, 2022
Nice digging. I wonder why setup.py doesn't run into this. Is it because setup.py and meson use different |
rgommers commentedNov 24, 2022
It's because there |
stefanv commentedNov 24, 2022
Do you understand why |
rgommers commentedNov 24, 2022
Yes, it asks for strict C99 mode, not C99 + POSIX or "whatever the compiler can do". |
stefanv commentedNov 24, 2022
For future reference, looks like all this magic happens inside of Here is the diff between preprocessing directives with and without -#define linux 1-#define unix 1-#define __STDC_VERSION__ 201710L+#define __STDC_VERSION__ 201112L+#define __STRICT_ANSI__ 1 It's the I can confirm that setting @rgommers I've pushed a commit to your branch; not sure if a global flag is the right solution or not, so feel free to drop/replace the patch. |
rgommers commentedNov 25, 2022
I had a look, this silences the warning but isn't quite the right thing to do. The problem was that some files included standard library headers before they included I'll also note that you always want to use I suggest we close this PR. |
stefanv commentedNov 25, 2022
Closed by82fd2b8 For completeness, note that compilation now defaults to c99 and c++14. |
Uh oh!
There was an error while loading.Please reload this page.
The Python headers use this as, e.g.:
When GCC sees this, it complains that the definition of
timespecwill not be visible outside of the function declaration. However,timespecis defined intime.h.Forward definition is the fix pipewire applied
(https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/230).
Perhaps there is a better way?