Liste des Groupes | Revenir à cl c |
On 7/10/24 17:23, Keith Thompson wrote:
>Tim Rentsch <tr.17687@z991.linuxsc.com> writes:>
>Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:>
>Tim Rentsch <tr.17687@z991.linuxsc.com> writes:>
[...]
>This posting has inspired me to try using (long)0.0>
whenever a null pointer constant is needed. As for
example
>
(void*){ (long)0.0 }
>
as an argument to a variadic function where a pointer
is expected.
But surely ((void*)('/'/'/'-'/'/'/')) is more elegant.
Surely not. Furthermore the form I showed has a point,
whereas this example is roughly the equivalent of a
first grade knock-knock joke.
I was of course joking. I assumed you were as well.
>
What is the point of (void*){ (long)0.0 }? I don't believe it's
a null pointer constant even in C23.
I think you're right about that.
"An integer constant expression132) ... shall only have operands
that are ... compound literal constants of arithmetic type that
are the immediate operands of casts. ... Cast operators in an
integer constant expression shall only convert arithmetic types to
integer types, ...", so (long)0.0 is permitted."
>
While (void*) looks like a cast, in this context it is a compound
literal of pointer type, which is not allowed. [..]
Les messages affichés proviennent d'usenet.