[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, 1000there 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.