[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Best practice in C to support 64-bit or 32-bit address length with same source file ?
- From: Ken Raeburn <raeburn raeburn org>
- To: Linux on Alpha processors <axp-list redhat com>
- Subject: Re: Best practice in C to support 64-bit or 32-bit address length with same source file ?
- Date: Sun, 4 May 2008 11:05:04 -0400
On May 3, 2008, at 16:49, Davis Johnson wrote:
Rule 1 includes using NULL for null pointer values and not 0. It
also includes using %p to format pointer values. There are probably
some other things I should add.
NULL may be defined as 0, though. In calling a variadic function like
printf, *always* cast NULL (or 0) to the correct pointer type expected
by the function; the compiler should automatically convert NULL or 0
as needed in most other contexts. In fact, for variadic functions,
you should also make sure your integral-typed arguments are of the
correct types, because passing a 64-bit long where the function
expects a 32-bit int (or vice versa) may cause a mismatch in stack
layout calculations.
Ken
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]