Who has for me a good piece of software to convert COBOL record to C -records.
The datatypes in the records can be various ? I have something to do it, but
it is not very elegant.
Thanks in advance
Jan Pieters (email: ja...@xs4all.nl)
Jan, it rather depends on which implementations of COBOL and C you want to handle.
For example, the alignment of items within C structures is not covered
within the standard C language but rely on extensions such as #pragma pack()
which will need translating correctly. On the COBOL side you have problems
such as how to represent the C binary format. Although standard COBOL has
a binary datatype, its format is implementation specific.
Having overcome these problems, then there is the problem of actually making
use of the generated COBOL. Micro Focus has devised COBOL extensions for
COBOL type definitions so that a COBOL record can be described as a type
and then later COBOL items can be declared as having that named type in
a similar way to C.
So a qualified answer yes to your question. If the C is from a big-endian Unix
box or from Microsoft C or IBM C Set and the COBOL compiler you will be
using is Micro Focus V3.2 then the Micro Focus utility "H2cpy" should
give you all you want. There was an earlier version of h2cpy that was
much less effective, so make sure its from V3.2.
If its just a one-off file then email it to me and I'll whack it thru
the convertor for you.
Martyn Woerner.
I don't think that what you said is related to his question at all.
It appears to me that he wants to convert the data for a number of
Cobol files into something that can be easily accessed by C.
Though it may be that he just wants to convert Cobol FDs into
equivalent C structs, but as this is unlikely to be useful without
converting the data too, I doubt this is his request.
You seem to be answering how C structures could be used in a Cobol
program.
I don't quite get what you mean by 'COBOL' records to 'C' records. On the
PC platform I have files which I use in C based programs and COBOL based
programs with equal ease. Why would you need to 'convert' them. If you
are talking about COBOL record structures to C data structures (e.g.,
source code), then I would be interested to hear about it, too.