How to judge the problem of the size of the machine

xiaoxiao2021-03-06  61

How to determine the problem of the size of the machine, see it in the code of the ORBACUS, this is discharged.

int

Main ()

{

/ * Are We little or big endian? From Harbison & Steler. * /

union

{

Long L;

Char C [sizeof (long);

} u;

u.l = 1;

Exit (u.c [sizeof (long) - 1] == 1);

}

2.

#include

#include

int

Main ()

{

#if byte_order! = BIG_ENDIAN

NOT BIG ENDIAN

#ENDIF

;

Return 0;

}

3.

#include

#include

int

Main ()

{

#if! Byte_Order ||! BIG_ENDIAN ||! Little_ENDIAN

Bogus Endian Macros

#ENDIF

;

Return 0;

}

转载请注明原文地址:https://www.9cbs.com/read-112330.html

New Post(0)