LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* typecheck code
@ 2011-01-31 17:03 Sri Ram Vemulpali
  2011-01-31 17:20 ` Jamie Iles
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Sri Ram Vemulpali @ 2011-01-31 17:03 UTC (permalink / raw)
  To: Kernel-newbies, linux-kernel-mail

Hi all,

/*
 * Check at compile time that something is of a particular type.
 * Always evaluates to 1 so you may use it easily in comparisons.
 */
 #define typecheck(type,x) \
 ({      type __dummy; \
        typeof(x) __dummy2; \
        (void)(&__dummy == &__dummy2); \
        1; \
 })

#define typecheck_fn(type,function) \
({      typeof(type) __tmp = function; \
       (void)__tmp; \
})

Can anyone help me, explain the above code typecheck. How does
(void)(&__dummy == &__dummy2) evaluates to 1

I appreciate any explain.

-- 
Regards,
Sri.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-01-31 21:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-31 17:03 typecheck code Sri Ram Vemulpali
2011-01-31 17:20 ` Jamie Iles
2011-01-31 17:22 ` Geert Uytterhoeven
2011-01-31 17:44 ` Rajat Sharma
2011-01-31 18:03 ` Manish Katiyar
2011-01-31 20:23   ` Sri Ram Vemulpali
2011-01-31 20:26 ` Dave Hylands
2011-01-31 21:42   ` julie Sullivan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).