Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix the type error when compiling :source:`Python/pytime.c` on the
MSYS2/UCRT64.
2 changes: 2 additions & 0 deletions Python/pytime.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,8 @@ pytime_as_timeval_struct(PyTime_t t, struct timeval *tv,
#ifdef MS_WINDOWS
// On Windows, timeval.tv_sec type is long
res2 = _PyTime_AsCLong(tv_sec, &tv->tv_sec);
#elif _UCRT
res2 = _PyTime_AsTime_t(tv_sec, (time_t *)&tv->tv_sec);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the correct fix. From the error message "expected 'time_t *' {aka 'long long int *'} but argument is of type 'long int *'" it can be seen that tv->tv_sec has type long int which is different from long long int.

Copy link
Contributor Author

@rruuaanng rruuaanng Nov 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually my initial thought was to start with struct timeval, but maybe that's not appropriate :(

Edit
(I actually think casting to the target type might be better than this.)

Edit2
Suddenly I remembered that struct timeval seems to be defined in the system header file.

#else
res2 = _PyTime_AsTime_t(tv_sec, &tv->tv_sec);
#endif
Expand Down
Loading