i have manged from accessing the unaligned memory address by using __packed before the pointer as follows:
Code:
int main ()
{
char* temp;
int x = 13;
temp = malloc(100);
*temp = 'a';
temp++;
*(__packed int*)temp = x;
temp +=4;
*temp = 'c';
return 0;}
so i want to ask 2 questions:
1. does __attribute__ ((packed)) have the same effect of __packed ? i.e.
is equivalent to
Code:
int* x __attribute__ ((packed));
or not?
2. when i tried to compile the following simple code :
Code:
int main ()
{
__packed char* temp;
return 0;
}
when i tried to compile it using arm-elf-gcc i got the following error:
Code:
main.c: In function `main':
main.c:28: `__packed' undeclared (first use in this function)
main.c:28: (Each undeclared identifier is reported only once
main.c:28: for each function it appears in.)
main.c:28: parse error before "char"
make: *** [main.o] Error 1
while when i tried to compile it using armcc ,
it was compiled suucessfully?
so should i search for the equivalence of __packed in arm-elf-gcc which is the toolchain i m wroking on, or there is something that should i include before using __packed.
thanks in advance