Silverfrost Forums

Welcome to our forums

passing strings back from C/C++ to FTN95

16 Mar 2018 1:49 #21621

an old chestnut but i'm driving myself round in circles trying to make this work!

i have a routine written in C under VS2017:

int checkout_(char *feature, char version, char option, char *mess)

And i want to set the 'mess' string back in FTN.

under VS, i can see that:

  •   mess	0x32a20ed0 \'Licensed number of users already reached.\\nFeature:       REP5\\nLicense path:  @localhost Licensing error:-4,132\'	char *
    

what do i have to set in my interface routine in FTN do get this back?

i've tried:

c_external checkout 'checkout_' (string, string, string, outstring) : integer4 c_external checkout 'checkout_' (string, string, string, string) : integer4 c_external checkout 'checkout_' (string, string, string, ref) : integer*4

with: ierr = checkout(feature_t, ver_t, opt_t, mess)

what's thee correct way to do it, pretty please!

K

16 Mar 2018 2:37 #21622

ok, i've worked out a way to do it:

in C: int checkout_(char *feature, char version, char option, char **mess)

in FTN: stdcall checkout 'checkout_' (string, string, string, ref) : integer*4

    iadd  =  loc(mess)
    ierr  = checkout(feature_t, ver_t, opt_t, iadd)

then the address IADD points to the string and can be copied byte-by-byte to a character variable, testing for CR or LF along the way.

not very elegant, but it seems to work.

K

16 Mar 2018 4:04 #21624

If you look at the Windows API calls, many contain a length parameter to define how long the result can be so as not to over-run buffers.

That is what I use when coding 'C' routines that need to return character values to FTN95.

Please login to reply.