Jump to page titleUNITED STATES
hp.com home products and services support and drivers solutions how to buy
» contact hp

:

more options
 

hp.com home
End of Jump to page title
Example C/PL1 Accessing The ERRNO Field In C From PLI
Jump to content



» 

business support center

Home & Home Office Support:
» HP branded products
» Presario branded products
» Services & Warranties
Small & Medium Business Support:
» Small & Medium Business products
» Small & Medium Business services
Support for IT Professionals:
» Enterprise products (IT Resource Center)
» NonStop enterprise products
» Business & IT Services
Content starts here
Copyright (c) Digital Equipment Corporation 1989. All rights reserved
LAYERED PRODUCT: PL1 V3.2, VAX C V2.4  OP/SYS: VMS V5.0-2

SOURCE:     Digital Customer Support Center


OVERVIEW:

This article demonstrates how to access the ERRNO field in C from a
PL1 program.


CAUTION:  This sample program has been tested using:

        PRODUCT: PL1 V3.2, C V2.4 on OPERATING SYSTEM: VMS V5.0-2

However, we cannot guarantee its effectiveness because of the possibility of
errors in transmitting or implementing it.  It is meant to be used as a
template for writing your own program, and it may require modification for use
on your system.


PROGRAM NOTES:

The PL1 program invokes the C subroutine, which generates an error.
The specific error number is returned to the C routine in the ERRNO field.
This field is then accessed by the PL1 (Main) routine.  It is made available
to the PL1 routine by overriding the default options of the ERRNO PSECT.
A linker options file is used make the ERRNO field shared, thus accessible
to the PL1 program.  Normally, ERRNO has NOSHR default.

Extract the following command procedure.  It contains a PL1 program,
a C subroutine, a linker options file and all commands required to
compile, link and execute.


PROGRAM SAMPLE:

$create PL1_C.PL1
callc: proc options(main);

dcl errno fixed bin(31) external;
dcl c_routine entry;
/* invoke the C routine */
call c_routine();
put skip list ('Errno (PL1 program):',errno);
end callc;
$create CERRNO.C
#include <math.h>
#include <errno.h>
#include <stdio.h>

int C_routine()

   {
    double x, y, z;
    errno = 0;
    x = 0;
    y = 0;
    z = pow (x, y);
     /* the above line will cause an error #33, this value can be
        found in the ERRNO field*/
   }
$create errno.opt
psect_attr=errno,shr,wrt,gbl,rd,ovr,long
sys$share:vaxcrtl.exe/share
$PL1 PL1_C.PL1
$CC CERRNO.C
$link PL1_C,CERRNO,ERRNO/OPT
$run PL1_C
$delete PL1_C.PL1;
$delete CERRNO.C;
$delete ERRNO.OPT;
$delete PL1_C.OBJ;
$delete CERRNO.OBJ;
$delete PL1_C.EXE;



buy online or call 1.800.AT.COMPAQ
privacy statementusing this site means you accept its terms