找回密码
 欢迎注册
楼主: mathe

[灌水] 测试c99编译功能

[复制链接]
发表于 2010-9-20 08:04:08 | 显示全部楼层
最近尝试的最小的图形化的操作系统是128M内存急速运行
当然别启动浏览器

郭,有兴趣用虚拟机虚拟个,可以获得原生的gcc支持
这个系统叫AntiX
无心人 发表于 2010-9-19 21:13


老兄最近不常见,很是想念。

不知你这个“郭”是不是叫我?
我比较懒惰,很少装这些新奇的东西体验,
对于开源代码,我更多是直接阅读揣摩,而没有去编译运行体验。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2010-9-20 10:13:23 | 显示全部楼层
VC2008,Od O2 都是65536
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2010-9-20 12:49:57 | 显示全部楼层
MinGW4.5.0,也是65536,加上 O2或者 O3,则为0
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2010-9-20 12:53:27 | 显示全部楼层
没有 return x; 的话,函数返回最后一个语句的值,即a的值。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2010-9-20 14:12:09 | 显示全部楼层
没有 return x; 的话,函数返回最后一个语句的值,即a的值。
wayne 发表于 2010-9-20 12:53

这是哪里的规定?我从来没有听过这个说法
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2010-9-20 16:01:52 | 显示全部楼层
对于Perl 脚本,的确是这样的。对于C语言,我到没有听说过这样的规定。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2010-9-20 17:02:02 | 显示全部楼层
15# mathe
哦,我的确说错了。
不过,我翻出来了以前写的代码,不知各位如何解释:
  1. #include<stdio.h>
  2. int gcd1(int m,int n){int t;  while(m!=0) t=m,m=n%m,n=t;}
  3. int gcd2(int m,int n){while(m-n) if(m>n) m-=n;else n-=m;}
  4. int lcm1(int a,int b){int m=a,n=b,t;  while(m!=0) t=m,m=n%m,n=t;return a/n*b;}
  5. int lcm2(int a,int b){int m=a,n=b;  while(m-n) if(m>n) n+=b;else m+=a;}
  6. int main(void){
  7. int m,n;
  8. printf("please input two positive integers:\n");
  9. scanf("%d%d",&m,&n);
  10. printf("GCD1(%d,%d)=\t%d\n",m,n,gcd1(m,n));
  11. printf("GCD2(%d,%d)=\t%d\n",m,n,gcd2(m,n));
  12. printf("LCM1(%d,%d)=\t%d\n",m,n,lcm1(m,n));
  13. printf("LCM2(%d,%d)=\t%d\n",m,n,lcm2(m,n));
  14. return 0;
  15. }
复制代码
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2010-9-21 11:58:12 | 显示全部楼层
17# wayne

当然了,这个在VS2008里面是不能通过的。
在GCC里面,加了-Wall,会提示:
control reaches end of non-void function
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2010-9-21 11:59:38 | 显示全部楼层
这么说来,这不是C语言的问题,而是编译器相关的问题。不知VC6怎么样
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-5-3 02:43 , Processed in 0.041249 second(s), 14 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表