Chinaunix首页 | 论坛 | 博客
  • 博客访问: 33233
  • 博文数量: 15
  • 博客积分: 351
  • 博客等级: 一等列兵
  • 技术积分: 105
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-22 12:34
文章分类

全部博文(15)

文章存档

2011年(15)

我的朋友

分类: C/C++

2011-01-29 21:09:24

片段

  1.   1 #include <stdio.h>
  2.   2
  3.   3 int main( int argc , char **argv )
  4.   4 {
  5.   5 unsigned int w = 32;
  6.   6 printf("1U << w : 0x%x\n" , 1U << w );
  7.   7
  8.   8 return 0;
  9.   9 }
  10.  10
在x86上 , 根据编译时是否进行优化 , 运行结果也不同
  1. 05:21:30-xuk@localhost:~/svn/goodbyeworld/binary-hacks/48$gcc main.c
  2. 05:21:46-xuk@localhost:~/svn/goodbyeworld/binary-hacks/48$./a.out
  3. 1U << w : 0x1


  4. 05:22:14-xuk@localhost:~/svn/goodbyeworld/binary-hacks/48$gcc -O2 main.c
  5. 05:22:54-xuk@localhost:~/svn/goodbyeworld/binary-hacks/48$./a.out
  6. 1U << w : 0x0

阅读(719) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~