f2py (1.20) drops definition`typedef signed char signed_char;` for callbacks in some circumstances
See original GitHub issueReproducing code example:
Unfortunately this is part of a larger project. And may be tricky to reproduce. Depending on other definition of callback functions, I get the error message below for the second routine.
this causes the error:
subroutine pyexit(code)
implicit none
integer(kind=4), intent(IN):: code
!f2py integer intent(in): code
!f2py intent(callback, hide) endkepler()
external endkepler
call endkepler()
end subroutine pyexit
!=======================================================================
subroutine pygets(ttymsg)
implicit none
character*(*), intent(inout) :: ttymsg
integer, parameter :: n = 132
integer :: i
integer(kind=1), dimension(n) :: data
!f2py intent(callback, hide) ttykepler(data)
external ttykepler
call ttykepler(data)
do i = 1, min(n, len(ttymsg))
ttymsg(i:i) = char(data(i))
end do
end subroutine pygets
but if I change the first routine to
subroutine pyexit(code)
implicit none
integer(kind=4), intent(IN):: code
!f2py integer intent(in): code
!f2py intent(callback, hide) endkepler(code)
external endkepler
call endkepler(code)
end subroutine pyexit
then the compilation error in the second routine does not occur.
Error message:
...
/tmp/tmp2skuwcza/src.linux-x86_64-3.9/_kepler_NBURN_8192_JMZ_1983_FULDAT_fuldat1_f_CPU_Intel_R_Xeon_R_W_2145_CPU_3_70GHzmodule.c:29:63: error: unknown type name ‘signed_char’; did you mean ‘signed char’?
29 | typedef void(*cb_ttykepler_in_pygets__user__routines_typedef)(signed_char *);
...
NumPy/Python version information:
1.20.0 3.9.1 (default, Dec 16 2020, 01:02:01) [GCC 10.2.1 20201125 (Red Hat 10.2.1-9)]
Issue Analytics
- State:
- Created 3 years ago
- Comments:21 (21 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@2sn could you change your local copy of numpy/f2py according to (it is one line only change)
https://github.com/numpy/numpy/pull/18350/files#diff-b1639eaf518e24317733541ac7fc4f58cf217666e339b0b9604e85460506a85a
to check if it fixes your use case.
I confirm, this fixed that issue for me! Thank you so much.