Sujet : Re: Casting the return value of ...
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 29. Mar 2024, 06:02:35
Autres entêtes
Organisation : None to speak of
Message-ID : <87r0ftsk9g.fsf@nosuchdomain.example.com>
References : 1 2
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Andrey Tarasevich <
andreytarasevich@hotmail.com> writes:
[...]
No, it isn't even remotely the same. C language allows implicit casts
from any object pointer type to `void *` and vice-versa. Which is why
casting the result of `malloc` is unnecessary.
To be picky, there are no "implicit casts". There are implicit
conversions. A cast is an explicit conversion.
C language does not support implicit casts between object pointer
types (like `void *`) and function pointer types. Moreover, C language
still does not support _explicit_ casts between `void *` and function
pointer types either. POSIX guarantees/requirements are not C.
It "does not support" them in the sense that it does not define their
behavior. Such a cast does not violate any constraint, and an
implementation or third-party standard is free to define the semantics.
By contrast, conversions between floating types and pointer types are
constraint violations.
[...]
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comWorking, but not speaking, for Medtronicvoid Void(void) { Void(); } /* The recursive call of the void */