1
0
mirror of https://github.com/cc65/cc65.git synced 2024-05-29 08:41:31 +00:00

Make NULL conform to POSIX

POSIX.1-2008 tightened the definition of NULL to be 0 cast to the
type 'void *'.

Defining NULL as 0 is problematic, because it requires users to
cast NULL to a pointer type before passing it to variadic
functions.  Using POSIX's definition is safer, because NULL can be
used in all contexts without a cast, due to the alignment of
'void *' and 'char *' being the same.  It also helps the compiler
be able to detect when NULL is being used in an integer context.

Link: <http://ewontfix.com/11/>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
This commit is contained in:
Alejandro Colomar 2022-08-08 21:48:32 +02:00
parent 4de40a20cb
commit f14e793197

View File

@ -54,7 +54,7 @@ typedef unsigned size_t;
/* NULL pointer */
#ifndef _HAVE_NULL
#define NULL 0
#define NULL ((void *) 0)
#define _HAVE_NULL
#endif