Standards / Extensions | C or C++ | Dependencies |
---|---|---|
z/OS® UNIX | both |
int __errno2(void);
The __errno2() function can be used when diagnosing application problems. This function enables z/OS XL C/C++ application programs to access additional diagnostic information, errno2 (errnojr), associated with errno. The errno2 may be set by the z/OS XL C/C++ runtime library, z/OS UNIX callable services or other callable services. The errno2 is intended for diagnostic display purposes only and it is not a programming interface. The __errno2() function is not portable.
The __errno2() function is always successful. The returned value is intended for diagnostic display purposes only.
The returned value may input to the BPXMTEXT utility to produce detailed information about the reported error if available.
For more information about the return value, see the z/OS UNIX System Services Command Reference, z/OS UNIX System Services Programming: Assembler Callable Services Reference, and z/OS Language Environment Debugging Guide.
⁄* CELEBE02
The following example's output only occurs
if the buffer is flushed.
*⁄
#include <errno.h>
#include <stdio.h>
int main(void) {
FILE *f;
f = fopen("notafile","r");
if (f==NULL) {
perror("fopen() failed");
printf("__errno2 = %08x\n", __errno2());
}
return(0);
}
Sample output of routine using __errno2(), CELEBE02:
fopen() failed: EDC5129I No such file or directory. __errno2 = 05620062
CELEBE08
#pragma runopts(posix(on))
#define _EXT
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
int main(void){
FILE *fp;
/* add errno2 to perror message */
setenv("_EDC_ADD_ERRNO2", "1", 1);
fp = fopen("testfile.dat", "r");
if (fp == NULL)
perror("fopen() failed");
return 0;
}
Sample output of routine using _EDC_ADD_ERRNO2, CELEBE08:
fopen() failed: EDC5129I No such file or directory. (errno2=0x05620062)
CELEBE09
#pragma runopts(posix(on))
#define _EXT
#include <stdio.h>
#include <errno.h>
int main(void){
FILE *f;
f = fopen("testfile.dat", "r");
if (f == NULL){
perror("fopen() failed");
printf("__errno2 = %08x\n", __errno2());
}
⁄* reset errno2 to zero *⁄
*__err2ad() = 0x0;
printf("__errno2 = %08x\n", __errno2());
f = fopen("testfile.dat", "r");
if (f == NULL){
perror("fopen() failed");
printf("__errno2 = %08x\n", __errno2());
}
return 0;
}
For more information about _EDC_ADD_ERRNO2 , see z/OS XL C/C++ Programming Guide. For more information about __err2ad() , see z/OS XL C/C++ Runtime Library Reference.