![]() |
2006-08-03
, 11:50
|
Posts: 503 |
Thanked: 267 times |
Joined on Jul 2006
@ Helsinki
|
#12
|
If you tell me the compiler directives to force stuff to be aligned, I'll try adding them in to (hopefully) the appropriate places.
#include <stdio.h> #include <stdlib.h> #include <stddef.h> #pragma pack(1) typedef struct s { char x; int y; } S; #pragma pack() int main() { int i; char *buffer = (char *)malloc(16); for (i = 0; i < 16; i++) buffer[i] = i; printf("reading unaligned value from the buffer at offset 1: %08X\n", *(int *)(buffer + 1)); printf("offsetof(S, y)=%d\n", offsetof(S, y)); printf("sizeof(S)=%d\n", sizeof(S)); free(buffer); return 0; }
reading unaligned value from the buffer at offset 1: 04030201 offsetof(S, y)=1 sizeof(S)=5
![]() |
2006-08-03
, 17:27
|
Posts: 105 |
Thanked: 1 time |
Joined on Feb 2006
|
#13
|
![]() |
2006-08-03
, 17:59
|
Posts: 105 |
Thanked: 1 time |
Joined on Feb 2006
|
#14
|
![]() |
2006-08-03
, 18:18
|
Posts: 105 |
Thanked: 1 time |
Joined on Feb 2006
|
#15
|
![]() |
2006-08-07
, 12:10
|
Posts: 105 |
Thanked: 1 time |
Joined on Feb 2006
|
#16
|
![]() |
2006-08-07
, 18:55
|
Posts: 105 |
Thanked: 1 time |
Joined on Feb 2006
|
#17
|
![]() |
2006-08-07
, 18:59
|
Posts: 503 |
Thanked: 267 times |
Joined on Jul 2006
@ Helsinki
|
#18
|
![]() |
2006-08-07
, 19:32
|
Posts: 105 |
Thanked: 1 time |
Joined on Feb 2006
|
#19
|
![]() |
2006-08-07
, 20:00
|
Posts: 319 |
Thanked: 6 times |
Joined on Apr 2006
|
#20
|
This is the answer:
char somedata [] __attribute__((aligned (4))) = {
.......
};
Anyone want the raw binaries, or wait for debs (which may be a little while!)
If you tell me the compiler directives to force stuff to be aligned, I'll try adding them in to (hopefully) the appropriate places.
Thanks!