Very good.
This makes code much cleaner because I do not have to send around both the
type field and node separately. Now I simply
void func(gpointer node) {
switch (NODE_TYPE(node)) {
case TYPE_1:
...
case TYPE_2:
...
}
}
// Osmo Antero
On Sat,
On Sat, 02 Jun 2012 00:04:18 -0400
Ernie Wright ern...@comcast.net wrote:
On 6/1/2012 2:17 PM, Osmo Antero wrote:
I have couple of C structures that I want to distinguish between by
reading the structures' first (type) field. [...]
Q: Can I assume that the type field is always first
On 6/2/2012 6:16 AM, Chris Vine wrote:
You are probably also interested in the strict aliasing rule, [...]
This is an alarmingly often overlooked rule.
In part because it wasn't in the standard prior to C99, which isn't
supported to the degree C90 is.
- Ernie
On Sat, 02 Jun 2012 09:10:06 -0400
Ernie Wright ern...@comcast.net wrote:
On 6/2/2012 6:16 AM, Chris Vine wrote:
You are probably also interested in the strict aliasing rule, [...]
This is an alarmingly often overlooked rule.
In part because it wasn't in the standard prior to C99, which
On 6/2/2012 11:30 AM, Chris Vine wrote:
In part because it wasn't in the standard prior to C99,
It was in C89 - ยง6.3:
Yes, you're right.
C99 added the 'restrict' keyword.
It is the fifth bullet point which permits your usage.
Not my usage, but yes, along with A pointer to a structure
On 6/1/2012 2:17 PM, Osmo Antero wrote:
I have couple of C structures that I want to distinguish between by
reading the structures' first (type) field. [...]
Q: Can I assume that the type field is always first in the
structures, so I can read it with: NodeType type = *(NodeType*)node;