Mail Archives: djgpp/1997/08/06/06:19:56
Paul Derbyshire wrote:
>
> In a program I am writing I am having problems using __attribute__ ((packed))
> on a struct meant for reading the (unpacked) records of a binary file
DJGPP comes with a very good example of how to use this attribute.
Look at the include/dos.h file how the struct _fint_t is declared.
BTW: There you can see, that you have to "pack" each element of the
struct and not only the struct at once.
> I am forced to conclude one of three things is the case:
Here my guess about your problem:
You are using it in a C++ file?? (please include that information
in the furure, because C and C++ are sometimes different to program).
The description in the gcc docs are valid only for C and not for C++.
(I tried it now).
Here is the syntax, which can be used in both languages
typedef struct
{
char dummy2
char dummy2;
} foo __attribute__ ((packed));
But as said above this will not solve you problem, because
you have to pack EACH member of the struct.
BTW: All the above is nowhere written, I found it only
by trying it many times ago.
Robert
--
*****************************************************************
* Robert Hoehne, Fakultaet fuer Mathematik, TU-Chemnitz-Zwickau *
* Post: Am Berg 3, D-09573 Dittmannsdorf *
* e-Mail: Robert DOT Hoehne AT Mathematik DOT TU-Chemnitz DOT DE *
* WWW: http://www.tu-chemnitz.de/~rho *
*****************************************************************
- Raw text -