-
Notifications
You must be signed in to change notification settings - Fork 37
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
const attribute is removed from parameter of a function pointer #32
Comments
This looks a bit odd. But according to libclang, which DStep uses under the hood,
Why would DMD complain about this? |
Hmm, if I remove the typedef, i.e. during it into a variable declaration, libclang will see it as const. |
I've asked about this on the Clang mailing list. |
Because the callback signature doesn't match the C library? I've had that happen in other situations, not sure if it would here. If you mean that it's the linker that normally catches stuff like this, sure.
Yeah, if you turn it into an actual function declaration, it sees the parameter as const, just not when it's a function pointer. |
Right, when you use the function pointer. Yes, then DMD will complain.
It's not the function pointer that is the problem, it's the typedef. |
I got a reply [1] from the mailing list and this is apparently how C behaves. I'm not sure that I can do anything about it. |
Perhaps D should allow the callbacks anyway since |
I have no real inclination on what to do here, I wasn't even sure it was a bug. I just reported it as I was double-checking the translation and it seemed like it might be. |
It behaves as it should according to C. But that will cause problems on the D side. I really, really don't want to parse C code without the help of Clang. |
I ran into this when translating the following:
typedef void (*AStorageManager_obbCallbackFunc)(const char* filename, const int32_t state, void* data);
DStep turned it into this, removing the const for the second parameter:
alias void function (const(char)*, int, void*) AStorageManager_obbCallbackFunc;
I haven't checked to see if dmd will actually complain about this, but it strikes me as a bug.
The text was updated successfully, but these errors were encountered: