Skip to main content

[Migrated content. Thread originally posted on 09 January 2012]

A function is defined as prototype, called by a cobol program in a C library.
      $set constant PS-rect "PS_rect"
       entry PS-rect void-conv using
               by value data-pointer
               by value      float
               by value      float
               by value      float
               by value      float
           .

PS_rect traces a rectangle according to this interface :
PSLIB_API void PSLIB_CALL
PS_rect(PSDoc *psdoc, float x, float y, float width, float height);

Here is the problem : if the cobol programs calls
                  call "PS_rect" using by value psdoc, 0, 0, 900, 1000
there is an error message at compilation time :
*1059-E*************************************************             
**    Parameter is not consistent with that defined in prototype     

If the program calls :
1 x usage float.
1 y usage float.
1 width usage float.
1 height usage float. *> all types defined correctly with typedef.
...
procedure division.
move 0 to x
move 0 to y
move 900 to width
move 1000 to height
call "PS_rect" using by value psdoc, x, y, width, height

Then, everything is alright.

Without prototype, the program runs but only zeroes are passed as parameter.

The question is : the function defined in a prototype, why can't the compiler process the numbers with their correct types (float here) ? Why to we have to use variables, put the correct values in the variables and then only call the function with variables instead of values ?
It makes the code considerably lenghty : 4 lines instead of 1.

Regards.

A.R.




[Migrated content. Thread originally posted on 09 January 2012]

A function is defined as prototype, called by a cobol program in a C library.
      $set constant PS-rect "PS_rect"
       entry PS-rect void-conv using
               by value data-pointer
               by value      float
               by value      float
               by value      float
               by value      float
           .

PS_rect traces a rectangle according to this interface :
PSLIB_API void PSLIB_CALL
PS_rect(PSDoc *psdoc, float x, float y, float width, float height);

Here is the problem : if the cobol programs calls
                  call "PS_rect" using by value psdoc, 0, 0, 900, 1000
there is an error message at compilation time :
*1059-E*************************************************             
**    Parameter is not consistent with that defined in prototype     

If the program calls :
1 x usage float.
1 y usage float.
1 width usage float.
1 height usage float. *> all types defined correctly with typedef.
...
procedure division.
move 0 to x
move 0 to y
move 900 to width
move 1000 to height
call "PS_rect" using by value psdoc, x, y, width, height

Then, everything is alright.

Without prototype, the program runs but only zeroes are passed as parameter.

The question is : the function defined in a prototype, why can't the compiler process the numbers with their correct types (float here) ? Why to we have to use variables, put the correct values in the variables and then only call the function with variables instead of values ?
It makes the code considerably lenghty : 4 lines instead of 1.

Regards.

A.R.




There appears to be a problem in the checker where it is assuming that the literal that you are passing by value is an integer and therefore gets the mismatch error.

I have created an RPI for this and passed it on to development.

One warning though about the use of parameter passing BY VALUE when COMP-1 or COMP-2 is used.

I spoke with development about this issue and you might be running into an undocumented limitation that COMP-1 and COMP-2 (float and double) data types can only be passed by value on x86 32-bit platforms.

Are you running this on an x86 32-bit platform?

This CALL ..BY VALUE comp-1 syntax is accepted by the compiler and will most likely work if it is a COBOL-->COBOL program call.

However if you are calling C on a non-x86 32-bit platform the C compiler will be expecting the value in a floating point register whereas COBOL will be passing it in a general purpose register instead.

This means that the actual values will not be passed correctly.

If you are not running on an x86 32-bit platform then you will need to create a C wrapper program which will intercept the COMP-1 values passed by reference and then do the actual call to the C API which requires that these parameters be passed by value.

[Migrated content. Thread originally posted on 09 January 2012]

A function is defined as prototype, called by a cobol program in a C library.
      $set constant PS-rect "PS_rect"
       entry PS-rect void-conv using
               by value data-pointer
               by value      float
               by value      float
               by value      float
               by value      float
           .

PS_rect traces a rectangle according to this interface :
PSLIB_API void PSLIB_CALL
PS_rect(PSDoc *psdoc, float x, float y, float width, float height);

Here is the problem : if the cobol programs calls
                  call "PS_rect" using by value psdoc, 0, 0, 900, 1000
there is an error message at compilation time :
*1059-E*************************************************             
**    Parameter is not consistent with that defined in prototype     

If the program calls :
1 x usage float.
1 y usage float.
1 width usage float.
1 height usage float. *> all types defined correctly with typedef.
...
procedure division.
move 0 to x
move 0 to y
move 900 to width
move 1000 to height
call "PS_rect" using by value psdoc, x, y, width, height

Then, everything is alright.

Without prototype, the program runs but only zeroes are passed as parameter.

The question is : the function defined in a prototype, why can't the compiler process the numbers with their correct types (float here) ? Why to we have to use variables, put the correct values in the variables and then only call the function with variables instead of values ?
It makes the code considerably lenghty : 4 lines instead of 1.

Regards.

A.R.




Thank you for this precise and useful information.

I am running a Centos 5.4 (=RHEL 5.4) version of Linux in 32 bits :
ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9,
dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped

Regards

[Migrated content. Thread originally posted on 09 January 2012]

A function is defined as prototype, called by a cobol program in a C library.
      $set constant PS-rect "PS_rect"
       entry PS-rect void-conv using
               by value data-pointer
               by value      float
               by value      float
               by value      float
               by value      float
           .

PS_rect traces a rectangle according to this interface :
PSLIB_API void PSLIB_CALL
PS_rect(PSDoc *psdoc, float x, float y, float width, float height);

Here is the problem : if the cobol programs calls
                  call "PS_rect" using by value psdoc, 0, 0, 900, 1000
there is an error message at compilation time :
*1059-E*************************************************             
**    Parameter is not consistent with that defined in prototype     

If the program calls :
1 x usage float.
1 y usage float.
1 width usage float.
1 height usage float. *> all types defined correctly with typedef.
...
procedure division.
move 0 to x
move 0 to y
move 900 to width
move 1000 to height
call "PS_rect" using by value psdoc, x, y, width, height

Then, everything is alright.

Without prototype, the program runs but only zeroes are passed as parameter.

The question is : the function defined in a prototype, why can't the compiler process the numbers with their correct types (float here) ? Why to we have to use variables, put the correct values in the variables and then only call the function with variables instead of values ?
It makes the code considerably lenghty : 4 lines instead of 1.

Regards.

A.R.




I forgot : I tried to "tell" the compiler that I use comp-1 using float parameters like in other languages
call "PS_rect" using by value psdoc, 0.0, 0.0, 900.0, 1000.0
But it does not understood what I was saying!

Regards.

[Migrated content. Thread originally posted on 09 January 2012]

A function is defined as prototype, called by a cobol program in a C library.
      $set constant PS-rect "PS_rect"
       entry PS-rect void-conv using
               by value data-pointer
               by value      float
               by value      float
               by value      float
               by value      float
           .

PS_rect traces a rectangle according to this interface :
PSLIB_API void PSLIB_CALL
PS_rect(PSDoc *psdoc, float x, float y, float width, float height);

Here is the problem : if the cobol programs calls
                  call "PS_rect" using by value psdoc, 0, 0, 900, 1000
there is an error message at compilation time :
*1059-E*************************************************             
**    Parameter is not consistent with that defined in prototype     

If the program calls :
1 x usage float.
1 y usage float.
1 width usage float.
1 height usage float. *> all types defined correctly with typedef.
...
procedure division.
move 0 to x
move 0 to y
move 900 to width
move 1000 to height
call "PS_rect" using by value psdoc, x, y, width, height

Then, everything is alright.

Without prototype, the program runs but only zeroes are passed as parameter.

The question is : the function defined in a prototype, why can't the compiler process the numbers with their correct types (float here) ? Why to we have to use variables, put the correct values in the variables and then only call the function with variables instead of values ?
It makes the code considerably lenghty : 4 lines instead of 1.

Regards.

A.R.




Yes, this is part of the same RPI, only integer numeric literals are recognized.

You should be OK on the platform that you mention as it is x86 32-bit but you will have to pass the data item by name instead of using the literal in the call statement.