#include < stdio.h >
#define PACKED __attribute__((packed))
typedef struct struct_Foo
{
char c;
int r;
long f;
} PACKED FOO;
typedef struct struct_Foo2
{
char c;
int r;
long f;
} FOO2;
int main(int argc, char* argv[])
{
printf ("Test arm...\n");
printf (" char : %2d\n", sizeof(char));
printf (" int : %2d\n", sizeof(int));
printf (" long : %2d\n", sizeof(long));
printf (" foo : %2d\n", sizeof(FOO));
printf (" foo2 : %2d\n", sizeof(FOO2));
}
and my Makefile:
# where is my tool chains for arm
BLD_NAME=greenphone
BLD_TOOL_VER = gcc-4.1.1-glibc-2.3.6
BLD_TARGET=arm-linux
BLD_PREFIX= /opt/toolchains/greenphone/$(BLD_TOOL_VER)
CROSS_COMPILE=$(BLD_PREFIX)/$(BLD_TARGET)/bin/$(BLD_TARGET)-
# tools... I am using
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
CFLAGS = -x c
all:
$(CC) $(CFLAGS) -o test test.c
result?
int : 4
long : 4
foo : 9
foo2 : 12