P
pemo
William said:Jordan Abel wrote:
Could someone provide an example of how to use this please - and
the typeof macro if poss?
typeof isn't a macro, it's a non-standard keyword. That's why it's
guarded by a HAVE_TYPEOF macro.
Ok, thatnks Jordan.
So, with this removed [whose keyword is it?],
AFAIK, typeof is a very common extension (GCC, TinyCC, TenDRA,
MSVC-maybe, Sun, IBM, HP). Basically, it's a magical operator that
can be used in-place of type declarations. So, you can do things
like:
int i;
typeof(i) d; /* d has the same type as i */
And, I dare say, given the reception in this forum of typeof, if I
were
a betting man I'd expect to see it in a future C standard. When typeof
is mentioned you'll typically get some gentle nudging about it's
non-existence in the C specification. However, for most other
non-C constructs you'll usually hear fire and brimstone speeches,
hopefully followed by convincing reasons why such a construct is a
poor idea, even on its own merits.
Also, the fact that typeof has found its way into so many compilers
also bodes well for inclusion. But, I suppose this discussion belongs
in comp.std.c
I mention this because alignof is also found in some compilers as an
operator, which is why I was interested in writing a macro. Unlike
typeof, however, it's not nearly as widespread, AFAIK.
Thanks for 'the gen' William.