Hi.
I need some help with a fortran callable C interface. The C interface
looks as follows:
extern int
MhGetMsgVaList (int message_code,
size_t max_message_size,
char * message_p,
...)
I have two main problems/concerns:
1) With IBM RS/6000 AIX Fortran you can specify %val or %ref
to pass by value or by reference - %ref also prevents the default
behavior of placing the length of the string at the end of the
parameter.
How portable is %val or %ref? The code being written does not
have to be highly portable, but it most likely will be ported to
HP/UX, Solaris, Irix, OSF/1.
I can get around this "problem" by have a special Fortran interface
where every parameter is a pointer to <type>.
2) The internal implementation calls vsprintf and by using the
above %val/%ref I have get short,int,* char, but have but
unable to get floats to work. The only way I have managed passing
floats is to explicitly specify as follows:
typedef
union param
{
char c;
short s;
int i;
long l;
float f;
intQuote:} param;
MhGetMsgVaList (int message_code,
size_t max_message_size,
char * message_p,
param *p1,
param *p2,
param *p3,
param *p4,
param *p5,
param *p6,
param *p7,
param *p8,
param *p9)
{
int i;
float f;
i = (*p2).i;
f = (*p3).f;
In reality, I would scan the message format (retrieved using theQuote:}
message_code parameter) to determine the type of each parameter.
This has the drawback of being much more difficult to implement, plus I
was only able to support specifying either float or double (not both, which
is can be done using variable list arguments for C function calls - I assume
that this might be because the parameters are always cast to a double?).
I have some problems with specifying a single byte integer, but that is
the least of my worries(until I resolve all my other problems).
What I don't understand is why I can pass Fortran integers and strings
through variable list parameters, but I when I try floats vsprintf always
outputs 0.0.
Any help would be greatly appreciated!!
--