File: endian.c

package info (click to toggle)
kinect-audio-setup 0.5-1
  • links: PTS, VCS
  • area: contrib
  • in suites: bookworm, bullseye, buster, sid, stretch, trixie
  • size: 220 kB
  • ctags: 34
  • sloc: ansic: 270; sh: 94; makefile: 69
file content (21 lines) | stat: -rw-r--r-- 471 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <stdlib.h>

static int little_endian(void) {
	int i = 0;
	((char *) (&i))[0] = 1;
	return (i == 1);
}

int main(void) {
	printf("#ifndef __ENDIAN_H\n");
	printf("#define __ENDIAN_H\n");
	printf("\n");
	printf("#define __LITTLE_ENDIAN 1234\n");
	printf("#define __BIG_ENDIAN    4321\n");
	printf("#define __BYTE_ORDER __%s_ENDIAN\n",
	       little_endian() ? "LITTLE" : "BIG");
	printf("\n");
	printf("#endif /* __ENDIAN_H */\n");
	exit(0);
}