The issue here is that your program uses the default COBOL entry-convention which expects a COBOL caller, but the caller was C.
For the first program You could use cob_call to do the calling (and afterwards likely a cob_cancel - or the combination of both with cob_func).
For a direct call from a C program you likely just want to adjust the entry-convention. The testsuite (tests/src/syn_misc.at in this case) has one C program that is similar to yours:
#include<stdio.h>#include<libcob.h> // only used for COB_EXT_EXPORT - not commonly neeededCOB_EXT_EXPORTintcprog(void*cb){char*p1;intp2=42;char*p3="CALLBACK";p1=p3;cob_call_entry(cb,3,p1,p2,p3);return0;}
and the following three different sample programs to show the possibilities you have:
Side note: GnuCOBOL 4.x will have an integrated runtime check for matching entry convention and if the caller is "extern" (= seems to not have been a COBOL program) then auto-adjust from COBOL entry convention to external one) - all those samples will still compile and work fine.
Last edit: Simon Sobisch 2021-05-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2021-05-10
Thank you for the fast answer.
Please excuse the short description.
This is a OpenCOBOL (cobol and c) and Enterprise COBOL (cobol and assembler) project with a lot of cobol main and subprogram (n parameter ATE1000) to c (n parameter ATE0000) and c (m parameter ATE0000) to cobol (m parameter ATE0001). OpenCOBOL is okay and GnuCOBOL 3.2 is for me okay if n >= m. The example work fine when i call in ATE0001 with a second dummy parameter in ATE0000 and add a second dummy parameter in ATE0001.
I prefer the same sources. OpenCOBOL and Enterprise COBOL differs in cobol copies. In the next days i test GnuCOBOL 4.0.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Does the source differ only if you use the entry convention? If not Where does they differ and did you actually specified -std=ibm (= what is the exact command line you've used)?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2021-05-12
On z/OS i use Enterprise COBOL. So the sources differ mainly in file declaration stored in copies. On Linux (and Windows) i use -std=ate. The coding is the same with some if respectively the environment. As attechment my compile/link and ate.conf.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My problem with r4211 3.2-dev.0.
The COBOL main program ATE1000
The C subprogram ATE0000.c
The COBOL subprogram ATE0001
ATE1000 abort with
Above i removed the directories and the sorces are without comments. The line numbers are correct.
What is my mistake?
The issue here is that your program uses the default COBOL entry-convention which expects a COBOL caller, but the caller was C.
For the first program You could use
cob_callto do the calling (and afterwards likely acob_cancel- or the combination of both withcob_func).For a direct call from a C program you likely just want to adjust the entry-convention. The testsuite (tests/src/syn_misc.at in this case) has one C program that is similar to yours:
and the following three different sample programs to show the possibilities you have:
all compiled with
cobc --debug -x -Wno-unfinished progN.cob cprog.cI guess that helps?
:-)
Side note: GnuCOBOL 4.x will have an integrated runtime check for matching entry convention and if the caller is "extern" (= seems to not have been a COBOL program) then auto-adjust from COBOL entry convention to external one) - all those samples will still compile and work fine.
Last edit: Simon Sobisch 2021-05-07
Thank you for the fast answer.
Please excuse the short description.
This is a OpenCOBOL (cobol and c) and Enterprise COBOL (cobol and assembler) project with a lot of cobol main and subprogram (n parameter ATE1000) to c (n parameter ATE0000) and c (m parameter ATE0000) to cobol (m parameter ATE0001). OpenCOBOL is okay and GnuCOBOL 3.2 is for me okay if n >= m. The example work fine when i call in ATE0001 with a second dummy parameter in ATE0000 and add a second dummy parameter in ATE0001.
I prefer the same sources. OpenCOBOL and Enterprise COBOL differs in cobol copies. In the next days i test GnuCOBOL 4.0.
Does the source differ only if you use the entry convention? If not Where does they differ and did you actually specified
-std=ibm(= what is the exact command line you've used)?On z/OS i use Enterprise COBOL. So the sources differ mainly in file declaration stored in copies. On Linux (and Windows) i use -std=ate. The coding is the same with some if respectively the environment. As attechment my compile/link and ate.conf.
Sounds good - but there's no attachment in your post.
Edit: now found in [1099957f8a]
Related
Discussion: 1099957f8a
Last edit: Simon Sobisch 2021-05-12