pll:谁使用_Bool [英] pll: who uses _Bool

查看:65
本文介绍了pll:谁使用_Bool的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁使用过_Bool? (或包括stdbool.h for bool,true,false?)


(我考虑在图书馆中用于家庭项目)

解决方案



" Szabolcs Nagy" < ns ******* @ gmail.comwrote in message


谁使用了_Bool? (或包括stdbool.h for bool,true,false?)


(我考虑在图书馆中用于家庭项目)



这就是Dennis Ritchie对此所说的话


在新事物中,限制指针可能是一种帮助; variadic宏

和bool只是装饰。我已经听说过很长一段时间的复杂数字的论证,也许这是不可避免的,但它确实增加了类型规则的交叉产品的价值。给图书馆充气。

问题没有提到的一个问题是引入了long long。类型及其

的含义,这是讨论中更有争议的问题之一

关于语言的小组 - 它也使类型推广规则更多

更复杂。但当然,这里有64位机器和存储器,并且必须面对它们。
http://www.itworld.com/Comp/3380/lw-12-ritchie/
<不过,
使用bool而不是_Bool。 Bool打破了图书馆。


-

免费游戏和编程好东西。
http://www.personal.leeds.ac.uk/~bgy1mm


Szabolcs Nagy写道:


谁使用了_Bool? (或包括stdbool.h for bool,true,false?)


(我考虑在家庭项目的库中使用它)



因为< stdbool.hisn'在所有相关的编译器上都没有,所以我仍然打算使用我自己的布尔定义。我现在应该改用小写

,使用ala:


#ifdef __STDC_IEC_559__

#include< stdbool .h>

#else

typedef enum {false,true} bool;

#endif


-

Tor< bw **** @ wvtqvm.vw | tr i-za-h a-z>


我的C页: http://www.pg2.moo.no/C/index.html

-include夹板的Win32版本3.1.2


Szabolcs Nagy写道:


谁使用了_Bool? (或包括stdbool.h for bool,true,false?)


(我考虑在图书馆中用于家庭项目)



恕我直言,bool(或_Bool)与静态内联(以及

优化编译器)齐头并进。否则,你将立即支付性能

和代码大小对语法糖的惩罚,如果你不需要

护理,C可能不是正确的语言你的项目。

我的意思是,除了类型,语义布尔值不是免费的:

int cmpneq(int a,int b){return a!= b;}

效率低于

int cmpneq(int a,int b){return ab;}


-

方舟


who has used _Bool? (or included stdbool.h for bool, true, false?)

(i''m considering using it in a library for home projects)

解决方案


"Szabolcs Nagy" <ns*******@gmail.comwrote in message

who has used _Bool? (or included stdbool.h for bool, true, false?)

(i''m considering using it in a library for home projects)

Here''s what Dennis Ritchie has to say about it

"Of the new things, restricted pointers probably are a help; variadic macros
and bool are just adornment. I''ve heard the argument for complex numbers for
a long time, and maybe it was inevitable, but it does somewhat increase the
cross-product of the type rules and inflate the library. One issue the
question didn''t mention is the introduction of the "long long" type and its
implications, which is one of the more contentious issues in discussion
groups about the language -- and it also makes the type-promotion rules much
more complicated. But of course, 64-bit machines and storage are here, and
it had to be faced."
http://www.itworld.com/Comp/3380/lw-12-ritchie/

use bool not _Bool, though. Bool breaks libraries.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm



Szabolcs Nagy wrote:

who has used _Bool? (or included stdbool.h for bool, true, false?)

(i''m considering using it in a library for home projects)

Since <stdbool.hisn''t available on all the relevant compilers, I stil
roll my own boolean definitions. I should perhaps switch to lower-case
now, using something ala:

#ifdef __STDC_IEC_559__
#include <stdbool.h>
#else
typedef enum {false, true} bool;
#endif

--
Tor <bw****@wvtqvm.vw | tr i-za-h a-z>

My C page: http://www.pg2.moo.no/C/index.html
-include Win32 build of splint 3.1.2


Szabolcs Nagy wrote:

who has used _Bool? (or included stdbool.h for bool, true, false?)

(i''m considering using it in a library for home projects)

IMHO, bool (or _Bool) goes hand in hand with static inline (and an
optimizing compiler). Otherwise, you will immediately pay performance
and code size penalties for syntactic sugar, and if you don''t have to
care, C might not be the right language for your project.
I mean, types aside, semantic Booleans are not free:
int cmpneq(int a, int b) {return a!=b;}
is less efficient than
int cmpneq(int a, int b) {return a-b;}

--
Ark


这篇关于pll:谁使用_Bool的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆