C程序员!你如何使用'工会'? [英] C programmers! How do you use your 'union's ?
问题描述
亲爱的伙伴们,
这是对上述C结构的常见(且不常见)非常重要的b $ b使用的另一项调查。
它是由同样的普通C程序员发布的,他们对'enum'的用法做了类似的
调查。
我知道空间优化是''union'背后的关键理念,在
大多数情况下,需要一个类型字段来验证实体的类型
''union''变量中的
。
我只是好奇我的老同事如何利用
C的这个特性他们的实现基于不同的编程风格
多样化的应用领域。
感谢您的关注。
此致,
// rk
" Razmig K" < ST ********* @ postmaster.co.uk>在消息中写道
这是对上述C结构的常见(且不常见)非常重要的使用的另一项调查。
我的程序是几乎是一个无联合区。
我只是好奇我的老同事如何在各种应用领域中基于不同编程风格的实现中利用这个功能。 / blockquote>
使用一个地方的工会是在X Window系统中。这个想法是
客户端和X服务器可以驻留在不同的机器上,并且数据包可以通过网络获得
。一个明显的优化是使每个数据包的大小固定为
,类型字段告诉你如何解释数据 - 鼠标
点击,重绘请求等因此消息实现为
联盟。
Malcolm写道:
我的程序是几乎没有工会区。
另一票:同样
-
| _ CJSonnack <章*** @ Sonnack.com> _____________ |我的节目怎么样? |
| _ http://www.Sonnack.com/ ___________________ |致电:1-800-DEV-NULL |
2003年8月15日09:29:12 -0700 , st*********@postmaster.co.uk (Razmig K)
写道:
亲爱的伙伴,
这是另一项对普通(且不常见)不平凡的调查
使用前面提到的C构造。
它是由同一个普通的C程序员发布的,他对'enum'的用法做了类似的调查。
<我知道空间优化是''union'背后的关键理念,而且在大多数情况下,需要一个类型字段来验证实体的类型
''变量。
我只是好奇我的老同事如何在各种应用领域中基于不同编程风格的实现中利用这个功能。 / BLOCKQUOTE>
在我最大的项目中,10岁并且变得强大,我在~500K行的C代码中找到了'* union''的两个*用法。
如果我今天重构代码库的任何一个区域,我会得到
摆脱它们。
- Sev
Dear mates,
This is an another survey for the common (and uncommon) nontrivial
uses of the aforementioned C construct.
It''s posted by the same average C programmer who''s made a similar
survey about the uses of ''enum''s.
I know that space optimization is the key idea behind ''union''s, and in
most cases a type-field is necessary to verify the type of the entity
in the ''union'' variable.
I''m just curious about how my elder colleagues utilize this feature of
C in their implementations based on diverse programming styles in
diverse application domains.
Thank you for your interest.
Best regards,
//rk解决方案
"Razmig K" <st*********@postmaster.co.uk> wrote in message
This is an another survey for the common (and uncommon) nontrivial
uses of the aforementioned C construct.
My programs are pretty much a union-free zone.
I''m just curious about how my elder colleagues utilize this feature of
C in their implementations based on diverse programming styles in
diverse application domains.
One place unions are used is in the X Window system. The idea is that the
client and the X server can reside on different machines, and packets can go
over a network. An obvious optimisation is to make each packet of fixed
size, with a type field telling you how to interpret the data - a mouse
click, a request to redraw, etc. The messages are therefore implemented as
unions.
Malcolm wrote:
My programs are pretty much a union-free zone.
Another vote for: Likewise
--
|_ CJSonnack <Ch***@Sonnack.com> _____________| How''s my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|___ ____________________|
On 15 Aug 2003 09:29:12 -0700, st*********@postmaster.co.uk (Razmig K)
wrote:
Dear mates,
This is an another survey for the common (and uncommon) nontrivial
uses of the aforementioned C construct.
It''s posted by the same average C programmer who''s made a similar
survey about the uses of ''enum''s.
I know that space optimization is the key idea behind ''union''s, and in
most cases a type-field is necessary to verify the type of the entity
in the ''union'' variable.
I''m just curious about how my elder colleagues utilize this feature of
C in their implementations based on diverse programming styles in
diverse application domains.
In my largest project, 10 years old and going strong, I found exactly
*two* uses of ''union'' in ~500K lines of C code.
And were I refactoring either area of the code base today, I would get
rid of them.
- Sev
这篇关于C程序员!你如何使用'工会'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!