kernel modules programming: struct proc question
Jacques A. Vidrine
nectar at FreeBSD.org
Wed Mar 17 09:53:44 PST 2004
On Wed, Mar 17, 2004 at 04:45:30PM +0100, Toni Andjelkovic wrote:
> On Wed, Mar 17 2004 (17:00:02 +0200), Artis Caune wrote:
> > "pid_t" is signed int type, or am I missing something?
>
> You are right, pid_t is __int32_t, which is signed, so "%d"
> is the correct format.
That's only correct for machines with 32-bit ints. In any case, POSIX
only specifies that pid_t is a signed integer type... it could be any
size supported by the implementation. For portability, you probably
want to cast to the `biggest' type and use the appropriate printf
specifier, e.g.
printf("%ld", (long)pid_t);
or
printf("%jd", (intmax_t)pid_t); // C99
Cheers,
--
Jacques Vidrine / nectar at celabo.org / jvidrine at verio.net / nectar at freebsd.org
More information about the freebsd-hackers
mailing list