Silverfrost Forums

Welcome to our forums

STDCALL and C_EXTERNAL improvement

10 Sep 2014 3:31 (Edited: 11 Sep 2014 5:03) #14610

It would be nice to get support for variable number of arguments in STDCALL and C_EXTERNAL.

It could be defined with ..., something like:

C_EXTERNAL name 'alias' (INSTRING, ...)

I am currently prototyping a library for interfacing with COM (Component Object Model) directly from FTN95 and this functionality would be handy.

Currently I am forced to use something like, or is there a better way?:

integer :: pObject
integer :: argv(1)
character(20) :: fname

fname = 'test.txt'C
argv(1) = loc(fname)

call COMinit()
pObject = COMnew('Demo.Application')
call COMcall(pObject, 'Open', '%s', 1, argv)
call COMrelease(pObject)
call COMclose()

Basically, I am using a printf() style format string to define types of the variable number of arguments. Arguments are passed as a vector of pointers to parameters. I also pass the number of arguments for the function.

With support for variable number of arguments, I could get rid of argument vector and just pass the actual arguments for the function and let compiler worry about the rest.

10 Sep 2014 6:59 #14611

Try using a signature with just one REF argument. It might work for C_EXTERNAL apart from getting a load of warnings and these could be suppressed. I don't have time at the moment to try it. STDCALL is more tricky because of the decoration for the number of bytes passed.

Unfortunately we would not be able to provide the extension in the short to medium term.

10 Sep 2014 10:07 #14612

This is probably a stupid comment of mine, but as Jalih is working on a COM interface, and at least one other user wants that functionality (asked for recently in the forum), might it not be worth giving Jalih whatever he needs for STDCALL and C_EXTERNAL to do it for you?

Unfortunately I haven't a clue what a COM object is, and wouldn't recognise one it if came up to me and bit me!

E

Please login to reply.