-
Notifications
You must be signed in to change notification settings - Fork 35
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
Portmidi header change breaks old code #72
Comments
I don't see the PR - maybe that was to fix pypm.c? One way to handle this is to cast Pt_Time to PmTimeProcPtr if you want to use it as a PmTimeProcPtr. Pt_Time does not require a parameter. I'm not too clear on whether this is still correct C or it just works (it was certainly correct on earlier C compilers). But, it's certainly not the cleanest approach. Changing the type signature of Pt_Time is really an incompatible change, but I think it's the right thing to do. It means any direct call to Pt_Time should change to Pt_Time(NULL). |
Here's the PR on our end if you're curious about our fix: pygame-community/pygame-ce#2863
This was my first instinct too, but I couldn't figure out how to generate that C code out of Cython (the Python-esque language that generates into pypm.c) |
We still get an error when trying to case https://github.com/PortMidi/portmidi/blob/master/pm_common/portmidi.h#L339 |
You tried |
Yes, here's exactly what the code looks like: err = Pm_OpenInput(&(self.midi), input_device, NULL, buffersize,
<PmTimeProcPtr>&Pt_Time, NULL) And the compiler error
|
This is not C or C++. I guess you are saying the solution for C programs: |
That is the Cython equivalent, the |
I'll try to manually compile the cython without the cast, then do the C-style cast in the C manually to see what happens |
Ok, yeah, manually casting it in the generated C does fix the problem. I've opened an issue with cython to report a potential bug in casting here |
Thanks for doing the test. Although it does sound like cython should work differently, I now also think Pt_Time should match PmTimeProcPtr and I should change all PmTimeProcPtr to PtTimeProcPtr so that the type of the time function will be declared in porttime.h. That will eliminate some casts, enable more type checking, but probably break something else. It shouldn't affect any binaries though. |
Hello, I work on maintaining pygame-ce, which uses portmidi for the
pygame.midi
moduleWe've recently seen compiles start to fail in our autogenerated pypm.c
From my research, it looks like the function
Pt_Time
used to be compatible withPmTimeProcPtr
, but now it is not.I think this broke here: 64314cc#diff-a92ece8a1b564c101a59ed27031b813d53906570f99c4f12bd09ac5f3b65fd82L79-R84
Apparently, in C, a function declaration with no args does not mean the function has no args-- https://stackoverflow.com/a/5929736/13816541. So Pt_Time() and Pt_Time(void) are different.
We have a PR to insert a shim to make
Pt_Time
used to be compatible withPmTimeProcPtr
on any version of portmidi, but I wanted to send in this bug report as an FYI.The text was updated successfully, but these errors were encountered: