[Info-vax] COBOL PIC format for a 64 bit unsigned int ("long long") ?

glen herrmannsfeldt gah at ugcs.caltech.edu
Tue Oct 13 04:41:01 EDT 2009


Jan-Erik S?derholm <jan-erik.soderholm at telia.com> wrote:
< Jim Duff wrote:
<> Jan-Erik S?derholm wrote:
<>> I am trying to call some COBOL code from a piece of C...

<>> The call from C looks like this :

<>>  char cob_inart[16];
<>>  unsigned long long cob_insernr;
<>>  char cob_utben[16];
<>>  char cob_utordnr[16];
<>>  int rc;

<>>  rc = MES101(cob_inart, cob_insernr, cob_utben, cob_utordnr);

<>> I get a ACCVIO when trying to use the "unsigned long long"
(snip(
 
< Outputs "INART" (as expected) and then ACCVIO's on the
< second DISPLAY. Anyway, see below...
 
(snip, I wrote)
 
< > I don't know specifically about COBOL, but calls from C to
< > many other languages expect the address of, not the value of,
< > the arguments.  For arrays that happens sort of automatically
< > (an array name is a constant pointer to the first element),
< > but not for scalars.  Try an & in front of the non-array.
 
(snip) 
< And also for my original code. I changed the type of the
< "unsigned long long" variable into a "pointer to unsigned
< long long", but the effect is the same...

No, that doesn't help and probably makes it worse.
Did you allocate any memory for the pointer to point to?
Did you add * to all references to it?  Instead, just put an &
in front of non-array arguments in the call.

  rc = MES101(cob_inart, &cob_insernr, cob_utben, cob_utordnr);

That tells C to pass the address of (a pointer to) cob_insernr
instead of the value.

-- glen



More information about the Info-vax mailing list