HP3000-L Archives

February 1995, Week 1

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:
Steve Elmer <[log in to unmask]>
Reply To:
Steve Elmer <[log in to unmask]>
Date:
Tue, 7 Feb 1995 21:13:44 GMT
Content-Type:
text/plain
Parts/Attachments:
text/plain (34 lines)
: If you are writing in HP C, don't forget
: #pragma intrinsic HPCIPUTVAR
 
I was asked -
 
> Ahhhh?  What happens if you forget the #pragma and run
> the program?  <evil grin>
 
I think the answer deserves a wider audience than a direct reply.
 
Many intrinsics, including HPCIPUTVAR, have optional and/or extensible
parameters.  Calling these routines requires some additioinal hidden
parameters that describe the rest of the parameter list.  You can think
of this as similar to the control string to a printf() call.  When the
#pragma intrinsic is used to declare the external routine, the compiler
uses the SYSINTR file to determine the exact parameter sequence, including
the hidden parameters.  When the SYSINTR file is not used, the caller is
responsible for passing the hidden parameters explicitly.
 
The simple rule is to _always_ declare #pragma intrinsic <intrinsic_name>
when calling intrinsics.  I think Stan has some utilities to help those
who aren't using HP C/iX and don't have the #pragma intrinsic.
 
Now, to answer the <evil grin>.  The most likely result is some form
of unexpected failure.  Since the SYSINTR file was not used, the hidden
parameters were not passed to the intrinsic.  Therefore, whatever parameter
is in the hidden parameter's position is interpreted as the hidden parameter.
This causes a logical shift of all the parameters downstream.  Most likely,
you'll get a bad parameter error of some sort back from the intrinsic.  In
some cases, you may actually cause the intrinsic to do some work, but it
probably won't be the work you thought you were asking for...
 
Steve

ATOM RSS1 RSS2