gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[open-cobol-list] Re: static cobol 2 c


From: Roger While
Subject: [open-cobol-list] Re: static cobol 2 c
Date: Sat Oct 22 13:24:43 2005

Adding to Gary's comments -
There are 2 more fundamental issues -
1)  The Little/Big endian consideration
2)  The field size

In order to directly use C short/int/long long, then binary fields
should be defined as COMP-5 (ie. Native byte order).
Also, the field length must be correct.
So,
PIC S9(4)   COMP-5              (signed) short
PIC 9(4)     COMP-5             unsigned short
PIC S9(8)   COMP-5              (signed) int
PIC 9(8)     COMP-5             unsigned int
PIC S9(18) COMP-5               (signed) long long
PIC 9(18)   COMP-5              unsigned long long

As Gary pointed out, if the short/int/long long field is not naturally
aligned, then you must pack the structure; eg gcc's attribute packed.

Roger





reply via email to

[Prev in Thread] Current Thread [Next in Thread]