I came across an expression in C like
typeof((c) + 1) _tmp = c;
What exactly does this mean?
Thanks for the reply.
Just on
In addition to the other answer, the +
here is quite subtle. It allows for c
to be either an expression or a type.
c
is promoted to int
(at least)
and the type of the whole expression
has at least integer rank of int
.c
make it a
cast of the value +1
. So then the resulting type is just c
.For both kinds of acrobatic it is important that c
is of arithmetic type and it is also to note that this trick here might loose the signedness of c
. So this use of the typeof
extension is not so useful as it might look like. In most cases using uintmax_t
or intmax_t
would be sufficient.