Liste des Groupes | Revenir à cl c |
On 2025-05-05, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>Michael S <already5chosen@yahoo.com> writes:>
>On Mon, 05 May 2025 01:34:16 -0700>
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>And more obviously, "%p" requires an argument of type void*, not>
int*.
That part of otherwise very good comment is unreasonably pedantic.
I disagree. I suggest it's a bad habit to use "%p" without
ensuring, by a cast if necessary, that the argument is of type
void*.
>
In most implementations, it's likely that all pointers have the
same size and representation and are passed as arguments in the
same way, but getting the types right means one less thing to worry
about.
If the codebade assumes all data pointers are the same size, bit
pattern and are treated the same in the calling conventions / ABI,
then it is probably moot.
>
That code is doomed on a platform where the assumption doesn't
hold, and the printf statemnts are probably not independently
reusable.
>
(I mostly put in these casts just to communicate to others that
an ISO C language lawyer works here, if you happen to need one.)
>
Also, it owuld be amazingly stupid of any such platform not just
make those printfs work: to promote variadic arguments of
pointer-to-object type to a common representation which is the
same as void *, combined with a matching behavior in the va_arg
macro for extracting the value back into any pointer-to-object
type.
Les messages affichés proviennent d'usenet.