-
Notifications
You must be signed in to change notification settings - Fork 39
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
Function typedefs drop type information #50
Comments
Yeah, at least in CL this isn't really necessary—it's just a typedef, and basically all you care about is it being a function-pointer type—so I never really bothered to add this information. If you're doing something fancy like code completion or similar, it could probably be added without a lot of trouble or breaking compatibility. I don't know if/when I'd have time to do this myself though. |
Interestingly, I think it is not a function pointer, but a function stand in, describing a function. This particular one is a problem for my FFI, as the function itself is never declared anywhere else - it is a callback function description. So yes, the actual return type and parameters are absolutely necessary in this context. |
Well, you can't actually use them for anything. It doesn't describe an actual function, just the "type" of a function. In C/C++, this is used more or less exclusively for validating a function pointer assignment, i.e., as per the post, if you were to do typedef int (functype)(void);
void bar(void) { .. }
functype *fn = bar; ...you'd probably get at least a warning. But in the context of Additionally for the declaration case in that post, you still get full declarations for the actual functions. In this case, it looks like a callback declaration type, which is probably used for passing "correct" function pointers around in C, but in CL it doesn't matter. You need to explicitly declare your |
Mostly agree. In my case I've written (well, not completely :)a cl library to inspect and reason about ffis generated by c2ffi (and possibly generate various kinds of bindings). With it I expect to be able to generate callback function types based on information collected, and oddly enough, the typedef above is the only description of the function. In any event, it seems that c2ffi's mission is to preserve any useful information for the next level to handle, and my argument here, is that the function type information is indeed useful. My goal is to gather a complete database of all types as seen by a particular incantation of c2ffi, be able to inspect it, and interactively select a useful subset (a tree-shake of sorts). It would be nice to have a complete record of types, and the typedef may be the only such record (proven by at least this one case). It is not a really important issue, but I'd love to see it fixed when you can. |
Yeah if you're doing something more fancy with the data, it could be useful. Will tag as feature. |
Thanks. |
Hello again. I am generating a spec from some raspbian headers. This header line:
typedef void VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T( void *state );
is translated to:
{ "tag": "typedef", "ns": 0, "name": "VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T", "location": "raspbian/usr/include/interface/vchi/message_drivers/message.h:156:14", "type": { "tag": ":function" } }
losing the void return type as well as the (void* state) parameter entirely.
I am using up-to-date 4.0 LLVM/CLANG this time:)
Any thoughts?
The text was updated successfully, but these errors were encountered: