fd2pragma inline entry for function that returns pointer to another function
In my dynamic library I have added a function that returns a pointer to another function. The function to be returned has the following signature;
Code:
int func(int,int) Code:
int (*getMyFunction())(int,int); Code:
int (*)(int,int) __getFunction(__reg("a6") struct Library *)="\tjsr\t-36(a6)"; Code:
int (*__getFunction(__reg("a6") struct Library *))(int,int)="\tjsr\t-36(a6)"; |
This is certainly a bug in fd2pragma, but not trivial to fix.
Usually such function pointer types are avoided in dynamic libraries. Or simply replaced by APTR. I would suggest to define the function pointer return value type with a typedefin your clib header: Code:
typedef int (*MYFUNCTYPE)(int,int); Code:
MYFUNCTYPE getFunction(void); |
Using typedef is the first thing that I tried. However it seems fd2pragma does not support that as it gave me an error. Reading the documentation I found the following;
"fd2pragma knows all standard parameter types defined in exec/types.h and dos/dos.h, all structures and some more types. All other #typedef's bring a warning. Do not use them in prototypes files!" This is why I then took the other approach. Quote:
|
Quote:
Otherwise you could still add the new typedef to fd2pragma.types. |
No it doesn't :(
It gives a warning and says it is going to handle the typedefs as int and then says it cannot find the prototype functions and finally says empty or partial file deleted. In short the inline file is not generated. Quote:
"MYFUNCTYPE : int (*)(int,int)" It does not seem to have worked. To be honest not a big fan of this solution as that would mean having to edit fd2pragma.types each time if trying to build on a new environment (at the moment placed it in C). Quote:
|
I think I will try and avoid them as well :)
Quote:
|
Quote:
Quote:
Now I was curious and tried to reproduce it. Using the following clib header and FD file: Code:
frank@nerthus cat clib/my_protos.h Code:
frank@nerthus fd2pragma -s 38 -c clib/my_protos.h -i my_lib.fd Code:
frank@nerthus fd2pragma -s 70 --voidbase -c clib/my_protos.h -i my_lib.fd |
Maybe you could switch to sfdc and provide sfd files...
Code:
==base FooBase Code:
#define foo(___fx) \ Code:
void * foo(void (* fx)(int,int * )); |
Quote:
|
Quote:
oh, ok... projects/sfdc/sfdc --target=m68kvbcc-amigaos --mode=macros x.sfd Code:
#ifndef _INLINE_FOO_H |
I have copied the exact code and its failing :(
I am running fd2pragma on workbench 3.1 - would that make any difference? Quote:
|
Quote:
So there is an alternative! Nice. Quote:
Code:
Ram Disk:> fd2pragma special 38 clib clib/my_protos.h my_lib.fd http://phoenix.owl.de/fd2pragma.tar.gz Or alternatively from the recent vbcc V0.9h binary archive. You can also try sfdc, as we learned from Bebbo, in case you have a cross-compiling environment with Perl installed somewhere. Nowadays you should prefer SFD files over FD anyway. |
All times are GMT +2. The time now is 19:55. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.