判断大端小端机器的两种方法

第一种,使用位段:#include <stdio.h>struct data{ unsigned int a:3; unsigned int b:2; unsigned int c:3;};int main(){ struct data abc; unsigned char* s = (unsigned char*) &amp;abc; *s = 0x99; if(abc.a == 1) printf("you are using big_endian machine\n"); else printf("you ...
2011-09-03 10:52 | 阅读 1197 次 | 评论 2 条

zz对_stdcall 的理解

在C语言中,假设我们有这样的一个函数:int function(int a,int b)调用时只要用result = function(1,2)这样的方式就可以使用这个函数。但是,当高级语言被编译成计算机可以识别的机器码时,有一个问题就凸现出来:在CPU中,计算机没有办法知道一个函数调用需要多少个、什么样的参数,也没有硬件可以保存这些参数。也就是说,计算机不知道怎么给这个函数传递参数,传递参数的工作必须由函数调用者和函数本身来协调。为此,计算机提供了一种被称为栈的数据结构来支持参数传递。栈是一种先进后出的数据结构,栈有一个存储区、一个栈顶指针。栈顶指针指向堆栈中第一个可用的数据项(被称为...
2010-09-01 19:39 | 阅读 743 次 | 评论 0 条

zz 浅谈字节序(Endianness)

原文出处:http://blog.sina.com.cn/s/blog_4833ae820100jorc.html阅读文件格式文档的时候看到关于字节序(Byte Order)的要求:For values which span more than a single byte, the multiple byte ordering followed is that of the Big Endian / Motorola standard. The most significant byte will occur first, the least significant byte last想...
2010-08-08 15:27 | 阅读 850 次 | 评论 0 条
浏览25442次