-
#include<stdio.h>
-
//return 0 is big_endian return 1 is small endian
-
int checkSystem()
-
{
-
union check
-
{
-
int i;
-
char ch;
-
}c;
-
c.i = 1;
-
return (c.ch == 1);
-
}
-
-
int main()
-
{
-
int j = 0;
-
j = checkSystem();
-
printf("ret=%d\n",j);
-
printf("return 0 is big_endian return 1 is small endian\n");
-
return 0;
- }
Makefile
- #CC=gcc
- CC=arm-linux-gcc
- CFLAGS= -g -Wall
- TAR= big_little
-
- ALL: $(TAR)
-
- big_little:big_little.c
- $(CC) $(CFLAGS) -o $@ $^