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

Type conversion from EDFFILE* to int* now causes error instead of warning (GCC 14.2+) #33

Closed
flyingfalling opened this issue Jan 16, 2025 · 4 comments

Comments

@flyingfalling
Copy link
Contributor

Compilation with recent GCC versions causes errors. The typedef in src/pyedfread/edf_read.pyx does not seem to be taking effect:

cdef extern from "edf.h":
    ctypedef int EDFFILE
    int * edf_open_file(
        const char * fname,
        int consistency,
        int load_events,
        int load_samples,
        int * errval,
    )
    int edf_get_preamble_text_length(EDFFILE * edf)
    int edf_get_preamble_text(EDFFILE * ef, char * buffer, int length)
    int edf_get_next_data(EDFFILE * ef)
    ALLF_DATA * edf_get_float_data(EDFFILE * ef)
    int edf_get_element_count(EDFFILE * ef)
    int edf_close_file(EDFFILE * ef)

Compilation causes errors such as:

src/pyedfread/edf_read.c:21365:39: error: passing argument 1 of ‘edf_get_float_data’ from incompatible pointer type [-Wincompatible-pointer-types]
      21365 |       __pyx_v_fd = edf_get_float_data(__pyx_v_ef);
            |                                       ^~~~~~~~~~
            |                                       |
            |                                       int *
      /usr/include/EyeLink/edf.h:362:58: note: expected ‘EDFFILE *’ but argument is of type ‘int *’

Temporary Workaround:

Add compile flag -Wno-incompatible-pointer-types

I.e. in setup.py:

<snip>
"extra_compile_args": ["-fopenmp", "-Wno-incompatible-pointer-types"], 
<snip>
@behinger
Copy link
Member

thanks for reporting!

I don't know enough about compilation with GCC, do you think this is something worth diving into to fix properly, or is your workaround something we could just merge?

@flyingfalling
Copy link
Contributor Author

I will submit a pull request, I just figured out why it was being ignored. To wit: it was not, they actually mixed int* and EDFFILE* in the pyx file.

The workaround is not ideal since it will only work for GCC, and of course it would hit other warnings/errors that maybe should not be ignored.

@flyingfalling
Copy link
Contributor Author

flyingfalling commented Jan 17, 2025

I submitted a pull request (#34) with the fixes.

I tested installation and loading an edffile after installation on two systems:

opensuse (tumbleweed): python 3.11.11, gcc 14.2.1

ubuntu 22.04: python 3.10.12, gcc 11.4.0

Both performed as expected (no errors during installation, and correct output)

@behinger
Copy link
Member

thank you! I merged it & added you as a contributor. Super helpful!!

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

No branches or pull requests

2 participants