From mboxrd@z Thu Jan 1 00:00:00 1970 From: "cris" To: help-gcc@gnu.org Subject: ALIGNMENT / going crazy with gcc-2.7.2-sparc-sun-sunos-4.1.3 Date: Fri, 17 Dec 1999 14:24:00 -0000 Message-id: <83earg$bgg$1@nslave1.tin.it> X-SW-Source: 1999-12/msg00260.html hi! how can i tell gcc to compile my programs using strict-alignment for data types? if i write smth like this: void *full_array = malloc(50); short *short_p = &(( (char*) full_array)[ N ]); printf("%hd\n",*short_p); if N is odd, i get a core dump! i'm using gcc 2.7.2 on an old sparc2 with SunOs 4.1.3, no way to upgrade the os or to get a newer build of gcc. i've searched in the doc., i've found -m switches regarding alignment for ibm machines, but none for sparc ones! i've also seen a SHORT_ALIGNMENT macro to be defined (gcc-info, "You can control compilation driver"), but i don't know WHERE to define it! please help, reply by email too! have a nice day :) From mboxrd@z Thu Jan 1 00:00:00 1970 From: "cris" To: help-gcc@gnu.org Subject: ALIGNMENT / going crazy with gcc-2.7.2-sparc-sun-sunos-4.1.3 Date: Fri, 31 Dec 1999 22:24:00 -0000 Message-ID: <83earg$bgg$1@nslave1.tin.it> X-SW-Source: 1999-12n/msg00260.html Message-ID: <19991231222400.7NXM2G_b_9u88F8SlkYFoTK_owtwRSF0Icjuf5vLocs@z> hi! how can i tell gcc to compile my programs using strict-alignment for data types? if i write smth like this: void *full_array = malloc(50); short *short_p = &(( (char*) full_array)[ N ]); printf("%hd\n",*short_p); if N is odd, i get a core dump! i'm using gcc 2.7.2 on an old sparc2 with SunOs 4.1.3, no way to upgrade the os or to get a newer build of gcc. i've searched in the doc., i've found -m switches regarding alignment for ibm machines, but none for sparc ones! i've also seen a SHORT_ALIGNMENT macro to be defined (gcc-info, "You can control compilation driver"), but i don't know WHERE to define it! please help, reply by email too! have a nice day :)