----------------------------------------------------------------------------------
* Using and Porting the GNU Compiler Collection (GCC)
Source:
http://sunsite.ualberta.ca/Documentation/Gnu/gcc-3.0.2/html_mono/gcc.html
* Welcome to the IBM Linux compiler information center (XL C/C++)
Source:
http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp
* MS Visual Studio2010, Visual C++ 10 and C++0x White Paper (Korean)
Source:
http://download.microsoft.com/download/1/9/4/194B6F74-8A72-482D-AF0E-31CE9D855372/VisualC.PDF
* MS Visual Studio 2010 (C++0x Only)
Source:
http://vsts2010.net/category/Visual%20Studio%202010
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
* Byte Alignment(Pading Alignment)
----------------------------------------------------------------------------------
1. GNU/Linux
typedef struct _TypeA {
int a;
long b;
double c;
char d[10];
unsigned short e;
}__attribute__(packed) DATA;
2. MS Visual C++
#pragma pack(push)
#pragma pack(1)
typedef struct _TypeA {
int a;
long b;
double c;
char d[10];
unsigned short e;
}__attribute__(packed) DATA;
#pragma pack(0)
#pragma pack(pop)
----------------------------------------------------------------------------------
* Labeled Element Extension
----------------------------------------------------------------------------------
1. ANSI-C standard extension
DATA data = {
.a = 10,
.b = 11,
.c = 12,
};
2. GCC Labeled Element Extension
DATA data = {
a: 10,
b: 11,
c: 12
};
----------------------------------------------------------------------------------
* Bitwise Operation
----------------------------------------------------------------------------------
#include
void main(void) {
// 0xFF 0xE0 (2byte Big-endian)
printf( "Little-Endian: %d", (0xe0 << 8 | 0xff) );
/*
* 4bytes Big-endian to Little-endian
int val = ((int)0x01 << 24) & 0xFF000000;
val |= ((int)0x01 << 16) & 0xFF0000;
val |= ((int)0x01 << 8) & 0xFF00;
val |= ((int)0x01);
*/
}
-----
Cheers,
June
댓글 없음:
댓글 쓰기