Created
February 27, 2019 11:04
-
-
Save lae0901/beb6886215b389354a430bd8536b25e0 to your computer and use it in GitHub Desktop.
Segmentation fault error when running _PGMCALL to call ILE program from C code running in PASE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// steve8c.c - use _PGMCALL to call ILE program, no parameters. | |
// to compile: | |
// gcc -o steve8c steve8c.c | |
#include <stdio.h> | |
#include <as400_protos.h> | |
int main(int argc, char *argv[]) | |
{ | |
int rc; | |
static ILEpointer ilep_sample1c __attribute__ ((aligned (16))); | |
void *parms_argv[1]; | |
printf("running ...\n"); | |
/* Set the IBM i pointer to the QGPL/SAMPLE1C *PGM object */ | |
printf("before _RSLOBJ32.\n") ; | |
rc = _RSLOBJ2(&ilep_sample1c, RSLOBJ_TS_PGM, | |
"SAMPLE1C", "QGPL" ); | |
printf("after _RSLOBJ32.\n") ; | |
parms_argv[0] = NULL; | |
rc = _PGMCALL( &ilep_sample1c, (void*)&parms_argv, 0); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
when I run the code I get "Segmentation fault(coredump) " on the _RSLOBJ2 function call. Why that error?
use gcc to compile:
gcc -o steve8c steve8c.c
then I run the code:
steve8c
running ...
before _RSLOBJ32.
Segmentation fault(coredump)
calling a CL program on the IBM i:
PGM
SNDMSG MSG('hello from sample1c') TOUSR(*SYSOPR)
endpgm
sample1c was compiled using CRTBNDCL command:
CRTBNDCL PGM(QGPL/SAMPLE1C) SRCFILE(QGPL/QRPGLESRC)
my gcc version. here is the gcc -v output:
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/QOpenSys/opt/freeware/bin/../libexec/gcc/powerpc-ibm-aix6.1.0.0/4.6.2/lto-wrapper
Target: powerpc-ibm-aix6.1.0.0
Configured with: ../gcc-4.6.2/configure --with-as=/usr/bin/as --with-ld=/usr/bin/ld --enable-languages=c,c++,fortran --prefix=/op
t/freeware --mandir=/opt/freeware/man --infodir=/opt/freeware/info --enable-threads --enable-version-specific-runtime-libs --disa
ble-nls --enable-decimal-float=dpd --host=powerpc-ibm-aix6.1.0.0
Thread model: aix
gcc version 4.6.2 (GCC)