Robby
2010-02-08 23:30:01 UTC
Hello,
As you all know, I used to use a non C compliant compiler. Now in the new C
compiler, I declared a NULL in a header file like this:
#define NULL 0
so I could pass NULL as a function parameter... stuff like this:
void f1(var1, NULL); ..... and so forth.
I recently upgraded the compiler's version and now this still works but the
compiler gives the follwoing warnings
KERNEL.h:53:1: warning: "NULL" redefined
In file included from C:/Program Files (x86)/Microchip/MPLAB C32
Suite/bin/../lib/gcc/pic32mx/3.4.4/../../../../pic32mx/include/GenericTypeDefs.h:58,
from C:/Program Files (x86)/Microchip/MPLAB C32
Suite/bin/../lib/gcc/pic32mx/3.4.4/../../../../pic32mx/include/peripheral/i2c.h:50,
from C:/Program Files (x86)/Microchip/MPLAB C32
Suite/bin/../lib/gcc/pic32mx/3.4.4/../../../../pic32mx/include/plib.h:46,
C:/Program Files (x86)/Microchip/MPLAB C32
Suite/bin/../lib/gcc/pic32mx/3.4.4/../../../../pic32mx/include/stddef.h:67:1:
warning: this is the location of the previous definition
which I think means they have added a new definition of NULL in one of their
files of their new compiler's version. So on the last warning above I double
clicked on it an it took me to the following line of the stddef.h file:
... other code
#ifndef __cplusplus
#define NULL ((void *)0) // <<<<<<<<<<<<<<
...other code
Now I know this question is probably better posted in the compiler's
specific forum, but I would like to ask something about the language. What
does this say exactly:
#define NULL ((void *)0)
NULL is a void pointer?? which still means 0 right?
So if I use NULL anywhere, I am substituting it by 0 right?
Why would someone do this as opposed to just do this:
#define NULL 0
All feedback greatly appreciated!
As you all know, I used to use a non C compliant compiler. Now in the new C
compiler, I declared a NULL in a header file like this:
#define NULL 0
so I could pass NULL as a function parameter... stuff like this:
void f1(var1, NULL); ..... and so forth.
I recently upgraded the compiler's version and now this still works but the
compiler gives the follwoing warnings
KERNEL.h:53:1: warning: "NULL" redefined
In file included from C:/Program Files (x86)/Microchip/MPLAB C32
Suite/bin/../lib/gcc/pic32mx/3.4.4/../../../../pic32mx/include/GenericTypeDefs.h:58,
from C:/Program Files (x86)/Microchip/MPLAB C32
Suite/bin/../lib/gcc/pic32mx/3.4.4/../../../../pic32mx/include/peripheral/i2c.h:50,
from C:/Program Files (x86)/Microchip/MPLAB C32
Suite/bin/../lib/gcc/pic32mx/3.4.4/../../../../pic32mx/include/plib.h:46,
C:/Program Files (x86)/Microchip/MPLAB C32
Suite/bin/../lib/gcc/pic32mx/3.4.4/../../../../pic32mx/include/stddef.h:67:1:
warning: this is the location of the previous definition
which I think means they have added a new definition of NULL in one of their
files of their new compiler's version. So on the last warning above I double
clicked on it an it took me to the following line of the stddef.h file:
... other code
#ifndef __cplusplus
#define NULL ((void *)0) // <<<<<<<<<<<<<<
...other code
Now I know this question is probably better posted in the compiler's
specific forum, but I would like to ask something about the language. What
does this say exactly:
#define NULL ((void *)0)
NULL is a void pointer?? which still means 0 right?
So if I use NULL anywhere, I am substituting it by 0 right?
Why would someone do this as opposed to just do this:
#define NULL 0
All feedback greatly appreciated!
--
Best regards
Roberto
Best regards
Roberto