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

Re: [rtl] off topic



>>>>> "Alexander" == Alexander Lichius <Alexander.Lichius@ruhr-uni-bochum.de> writes:
Alexander> Hi 

Alexander>   i have a question not really regarding rtlinux in
Alexander>   special. we have to communicate with our a/d adaptor
Alexander>   which is realtime capable on its own. the problem is that
Alexander>   the task which is installed directly on the adaptors cpu
Alexander>   was compiled under DOS/WINDOWS. The task running on the
Alexander>   pc (now under linux) was compiled with egcs - which has a
Alexander>   4-byte alignment in contrast to the 1-byte alignment from
Alexander>   DOS compilers. so all our structures are different in
Alexander>   size and we only transfer bullshit to and from the a/d
Alexander>   adaptor.  does anybody know the command line switch or
Alexander>   pragma to change the default alignment of gnu cc or
Alexander>   egcs??

Try using the following declarative construct for every involved
struct:
		       __attribute__ ((packed))

Test program (prints '8' without the attribute, '5' with it):

struct s {
    unsigned int i;
    char c;
    unsigned int j;
} __attribute__ ((packed)) a;
 
main()
{
    printf("offset = %d\n", ((unsigned int) &a.j) - ((unsigned int) &a));
}

Gilles                (Gilles.Courcoux@Col.Bsf.Alcatel.FR)