User: Password:
|
|
Subscribe / Log in / New account

The timer API: size or type safety?

The timer API: size or type safety?

Posted Dec 8, 2006 18:20 UTC (Fri) by giraffedata (subscriber, #1954)
In reply to: The timer API: size or type safety? by jzbiciak
Parent article: The timer API: size or type safety?

Is typeof() standard C or a GNU extension?

I'ts GNU C. But it looks like it isn't necessary for this technique.


(Log in to post comments)

The timer API: size or type safety?

Posted Dec 8, 2006 19:42 UTC (Fri) by jzbiciak (subscriber, #5246) [Link]

Are you certain? Let's look at that closely:

    typeof(*data) *p = data;
    timer->function = (void (*)(void *)) func;
    timer->data = (void *) p;
    (void)(0 && (func(p), 0));

I guess your statement is that the last line, (func(p)) could be rewritten as (func(data)) instead. I can see that.

The timer API: size or type safety?

Posted Jan 3, 2007 19:48 UTC (Wed) by rjbell4 (guest, #35764) [Link]

The reason you wouldn't necessarily do that is that "data" may actually be an expression that has a side effect, so you don't want to reference it twice.

The timer API: size or type safety?

Posted Jan 3, 2007 19:59 UTC (Wed) by jzbiciak (subscriber, #5246) [Link]

So, I guess typeof(*data) doesn't evaluate data then? I guess that makes sense.

The timer API: size or type safety?

Posted Jan 3, 2007 20:01 UTC (Wed) by jzbiciak (subscriber, #5246) [Link]

Actually, hold on... (0 && func(data)) shouldn't evaluate data a second time under any circumstances anyway.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds