HP3000-L Archives

May 1999, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Greg Fudala <[log in to unmask]>
Reply To:
Greg Fudala <[log in to unmask]>
Date:
Mon, 17 May 1999 21:11:23 GMT
Content-Type:
text/plain
Parts/Attachments:
text/plain (61 lines)
It works beautifully.  I think I will go ahead and post this on the
newsgroup so others can see.  The compiler needs the
'-Ae" option as I found out.  Thanks again.  This solution saves me.

Greg

#include <stdlib.h>
#include <stdio.h>

typedef long long int64;
union u_tag {
   int64 int64value;
   char cvalue[9];
} uval;

extern int64 pascalfunc(short i);

main()
{
   uval.int64value  = pascalfunc(123);
   uval.cvalue[8] = NULL;
   printf("myvar='%s'\n", uval.cvalue);
}

> a.out
myvar='TESTTEST'



        Stan Sieler <[log in to unmask]> 05/17/99 04:23 PM

To:     Greg Fudala/MIS/Circuit City
cc:
Subject:        Re: [HP3000-L] Calling Pascal from C



Hi Greg,

> hmmm... now that I think about it .... you say that if the size < 8, then
r28
> and r29 contain the data, not a pointer to the data.
> Wouldn't it work to have the C program somehow see this data?  By
directly
> referencing it somehow (with the * character perhaps?)

For the pac8 case, leave the Pascal alone and declare the C code like:

   extern int64 pascalfunc (short i);

and use a union (or cast) to convert the 64-bit "integer" into 8-bytes of
char.

> Content-Disposition: attachment; filename="pic09767.pcx"

Your emails to me come with some kind of picture attached to it.

--
Stan Sieler                                          [log in to unmask]
                                     http://www.allegro.com/sieler.html

ATOM RSS1 RSS2