[Cython] C data type and a C function() sharing the same name

Nikita Nemkin nikita at nemkin.ru
Sat Jun 1 16:12:08 CEST 2013


On Sat, 01 Jun 2013 19:29:17 +0600, Marin Atanasov Nikolov  
<dnaeon at gmail.com> wrote:

> Hello,
>
> Working on creating Cython wrappers for a C library I came across a  
> strange
> problem.
>
> I have in the C library a struct like this:
>
>  struct my_jobs;
>
> I also have this function, which returns the next job in the queue:
>
>  int my_jobs(struct my_jobs *jobs);
>
> Translating this into Cython and putting this in the .pxd file it looks
> like this:
>
>   cdef struct my_jobs
>   int my_jobs(my_jobs *jobs)
>
> During build I'm having issues because it seems that the function  
> my_jobs()
> is translated in a way that it should return a "int struct my_jobs".
>
> The real problem I see is that I cannot have a data type and a function
> sharing the same name.
>
> How can I overcome this issue? Suppose that I wrote the C API I could
> change that, but how would you really  solve this if you cannot touch
> what's in upstream?
>
> Any ways to solve this?

This question would be more appropriate on the cython-users mailing list.

Use renaming:
http://docs.cython.org/src/userguide/external_C_code.html#resolving-naming-conflicts-c-name-specifications

For example, rename the function:

     int my_jobs_func "my_jobs" (my_jobs *jobs)

or the struct:

     cdef struct my_jobs_t "my_jobs"

or both.

Best regards,
Nikita Nemkin


More information about the cython-devel mailing list