Subject: | |
From: | |
Reply To: | |
Date: | Mon, 17 May 1999 16:35:54 GMT |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
I can't get this to work. This pascal function (in a separate object file)
returns a pascal packed array [1..8].
I'd like to have a C program call it and get the result. It always returns
NULL. According to "HP C Programmer's Guide",
I am supposed to declare the return result as the struct "pac8" shown
below.
Any idea what to do? Thanks very much.
Greg Fudala
Circuit City Stores
[log in to unmask]
Pascal program testpas.p, to compile: pc testpas.p -c (creates testpas.o)
==========================================================
$os 'hpux'$ { ux }
$STANDARD_LEVEL 'EXT_MODCAL'$
$NOTES OFF$
$SUBPROGRAM$
$CODE_OFFSETS ON; TABLES ON$
program mytest;
type
pac8 = packed array [1..8] of char;
$SYSINTR '/usr/lib/paslib'$
function pascalfunc (hpsys : shortint) : pac8;
var
myvar : pac8;
begin
myvar := 'TESTTEST';
pascalfunc := myvar;
end;
BEGIN
END.
C program test.c, to compile: cc test.c testpas.o (creates a.out
executible)
==========================================================
#include <stdlib.h>
#include <stdio.h>
static struct pac8 {
char p[9];
} myvar ;
extern struct pac8 pascalfunc(short i);
main()
{
myvar = pascalfunc(123);
printf("myvar='%s'\n", myvar.p);
}
Run of the program
===========================================================
> a.out
myvar=''
|
|
|