2011/8/5 Zhang Cheng <steph...@googlemail.com>:
> 不一定,如果声明you为volatile,或者you的believe()方法返回值编译时不可预测,那编译器就不能优化了。
>
On 08/04/2011 11:49 PM, 小马xiaoma wrote:
> if(you.believe(it)==true || you.believe(it)==false)
> 这句会被编译器优化掉的。
then send one patch :)
- --
Best Regards
Xiangfu Liu
http://www.openmobilefree.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk47RwEACgkQRRAEFRxkgLSDJwCfc1phqmhNtLcNzPdYn/xre6pI
eMMAn1Mz4i5ZHL67anxwcLvRwt6cUKYQ
=F+6z
-----END PGP SIGNATURE-----
转载了一下: http://www.openmobilefree.net/?p=972
如有不妥,请告知 :)
great code.
- --
Best Regards
Xiangfu Liu
http://www.openmobilefree.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk47RykACgkQRRAEFRxkgLTdxACgmA/TP2+WyMHnfjoHofAaSPPd
d34An0ULaDmCpImok7auZ9Gue4l7m1Bf
=AOOs
-----END PGP SIGNATURE-----
On 08/05/2011 09:42 AM, Yico Gaga wrote:
> 至于你信不信,反正我是信了.
来个C的:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/fcntl.h>
int believe(int it, char * you)
{
int random;
int c;
random = open("/dev/random", O_RDONLY);
read(random, &c, sizeof(c));
if(!strcmp(you, "people")) {
printf("It doesn’t matter if you guys believe or not\n");
return c;
}
close(random);
printf("I believe!\n");
return 1;
}
int main()
{
int ret;
int it; /* you know */
char * you = "people";
char * I;
switch(believe(it, you)) {
default:
ret = believe(it, I);
}
if(ret)
printf("It's a miracle!\n");
printf("It just happened!\n");
return 0;
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk47TGoACgkQRRAEFRxkgLRc3QCgwAArZakU15fy7Gzt6CoaDs5d
fgIAoLmp1KzXHtg+oFklBGuFWV0sR04c
=LjoC
-----END PGP SIGNATURE-----
你们真是闲得蛋疼啊...
--
Thomas
Shanghai Linux User Group
http://ghosTunix.org
Twitter: @ghosTM55
I 也没有初始值,而且全局用不到 char *I.
On 08/05/2011 12:32 PM, Moore wrote:
> it 没有初始值,而且在 believe 函数里it 没有用到。
>
有注释
> I 也没有初始值,而且全局用不到 char *I.
写的太清楚不太好吧~ :)
- --
Best Regards
Xiangfu Liu
http://www.openmobilefree.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk47enAACgkQRRAEFRxkgLRkHQCgkgRgOX7Ms74b5GyUS+ptjgqs
2SQAoIf/VQM8R8qu7MOiO3g/LG7SEnPK
=94iv
-----END PGP SIGNATURE-----
random = open("/dev/random", O_RDONLY);
read(random, &c, sizeof(c));
if(!strcmp(you, "people")) {
printf("It doesn’t matter if you guys believe or not\n");
return c;
}
close(random);
On 08/05/2011 09:11 PM, Zhang Cheng wrote:
>
> if(!strcmp(you, "people")) {
> printf("It doesn’t matter if you guys believe or not\n");
>
>
> 在函数返回前,random没有被close()。这个函数被执行多次会导致fd太多,把程序挂掉。
嗯。这是个问题,
- --
Best Regards
Xiangfu Liu
http://www.openmobilefree.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk4774IACgkQRRAEFRxkgLSEVACdG+DW+Zz+iAlvbGixJIzGu+Gp
K48AoISu3el4YvPiJOLmg0vnaXBV0Dqv
=XyVG
-----END PGP SIGNATURE-----
On 08/05/2011 09:11 PM, Zhang Cheng wrote:
>
> 在函数返回前,random没有被close()。这个函数被执行多次会导致fd太多,把程序挂掉。
new version: http://www.openmobilefree.net/?p=972
- --
Best Regards
Xiangfu Liu
http://www.openmobilefree.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk478AsACgkQRRAEFRxkgLSucQCfRkcKOtZgusdUGbQXbd1Nhq7g
ccgAn3+E5RhNLgiQlcwXIw05WeAs780M
=L4Pt
-----END PGP SIGNATURE-----
On 08/07/2011 12:51 PM, Hugh wrote:
> #include <铁道部.h>
then we don't needs those code :)
int it;
char * I;
- --
Best Regards
Xiangfu Liu
http://www.openmobilefree.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk4+H04ACgkQRRAEFRxkgLRqsACfUu+dKk42aGAaQ2d0ha3dg2dO
SCgAn1MbV6g+SNpyf7F9ZeXxTpYQk63J
=GcQl
-----END PGP SIGNATURE-----