"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
"Todd C. Miller" <Todd.Miller@sudo.ws>
Subject:
Re: use size_t for loop indices to avoid signedness warnings
To:
Stefan Sperling <stsp@stsp.name>
Cc:
Ed Maste <emaste@freebsd.org>, gameoftrees@openbsd.org
Date:
Fri, 18 Dec 2020 08:54:33 -0700

Download raw body.

Thread
Something I find useful is a macro like the following:

/* sizeof() that returns a signed value */
#define ssizeof(_x)	((ssize_t)sizeof(_x))

Then I just use ssizeof(foo) when I need to compare against a signed
integer.

Opinions vary on whether it is better to hide the cast or not in
this way :-)

 - todd