MF define two copybooks, namely cbltypes.cpy and cblproto.cpy. These can be COPYed by library users to find the data types used by their libraries and their prototypes, respectively. They also define a few examples (#1, #2) of the copybooks in action.
As a suggestion, cbltypes.cpy could be made available by GnuCOBOL in order to maintain API compatibility with existing applications relying on MF's extensions. Types such as CBL_CHECK_FILE_EXIST rely on data types predefined by the implementation (presumably by cbltypes.cpy), such as cblt-fileexist-buf.
So far, I do not see GnuCOBOL defining any of this. Instead, GnuCOBOL's test suite just allocates a 16-byte buffer, presumably because the size of cblt-fileexist-buf is also 16 bytes, and writes each byte individually.
OTOH while I am aware GnuCOBOL does not support prototypes as of the time of this writing (similarly to GCC-COBOL), an empty stub of cblproto.cpy could at least maintain API compatibility with existing applications as long as prototypes are not supported. Once supported, it then be filled accordingly. Also, IBM recommends the use of function prototypes for several reasons.
Best regards,
Xavi (Symas Corporation)
GnuCOBOL fully supports prototypes as far as I know and also internally creates them when compiling. What we don't have yet ("just needs a patch") is someone that writes the prototype information to a specified file and reads it from there as well.
Those are heavily used for example in COBJAPI since years.
Moving our existing internal checks for runtime library calls (system.def) in cobc to function prototypes would already be possible and very useful, as we currently only do a partial check on those (like amount of arguments).
The same cannot be done with the intrinsic functions as prototypes work with fixed amount of arguments without reserved words, but we could possibly extend that.
Concerning the types - they came after the initial implementation also in MF/ACU/... their old documentation original - using system library calls without them is most reasonable :-)
... but yes, I'd like to include them in our distribution. They can then also be copied to GCC-COBOL.
For the two files mentioned (note - there are also related C header files for those) I'm already in contact with the FSF,.
I have prepared the following minimal reproducible example in a tarball that fails to build on GnuCOBOL
r5627:On this example, a program called
protoattempts to call a function, namelyfoo, whose prototype isCOPYed fromfoo.cpy. To my knowledge, the code example should be fully ISO COBOL 2023-compliant i.e., no MF extensions. However, as shown abovemain.cblfails to find thefoofunction, despite its declaration being right above it.The warning and error messages above and seem to indicate otherwise. Is there anything I am missing?
Does this mean the example above is expected to fail because of missing bits and pieces in the implementation?
... we don't support MF prototypes - patches welcomed for those, the non-standard extension for the standard feature itself is tracked under [feature-requests:#509]
Related
Wish List: #509