[Monetdb-developers] Signed/unsigned and NULL

I just figured that the following yields in a signed/unsigned warning: 1 void myfunc(char *s) { 2 if (s != NULL) { 3 ... 4 } 5 } The error occurs on line 2. I cannot find the definition of NULL, but I suspect it is defined like: #define NULL 0 Obviously 0 is signed while s (pointer) is not. Maybe we should use #define NULL (char*)0 instead?

Never mind On 24-10-2006 10:16:11 +0200, Fabian Groffen wrote:
I just figured that the following yields in a signed/unsigned warning:
1 void myfunc(char *s) { 2 if (s != NULL) { 3 ... 4 } 5 }
The error occurs on line 2. I cannot find the definition of NULL, but I suspect it is defined like: #define NULL 0
Obviously 0 is signed while s (pointer) is not. Maybe we should use #define NULL (char*)0 instead?

On 2006-10-24 10:16, Fabian Groffen wrote:
I just figured that the following yields in a signed/unsigned warning:
1 void myfunc(char *s) { 2 if (s != NULL) { 3 ... 4 } 5 }
The error occurs on line 2. I cannot find the definition of NULL, but I suspect it is defined like: #define NULL 0
Obviously 0 is signed while s (pointer) is not. Maybe we should use #define NULL (char*)0 instead?
Which compiler? Which options? No, do not redefine NULL. It is defined in the standard include files and should not be changed. -- Sjoerd Mullender

Just try with both void myfunc(unsigned char *s) { and void myfunc(signed char *s) { and you find out, whether you compiler be default defines char as signed or unsigned (and whether your systems/compilers header files define NULL as signed or unsigend) ;-) Stefan On Tue, Oct 24, 2006 at 10:16:11AM +0200, Fabian Groffen wrote:
I just figured that the following yields in a signed/unsigned warning:
1 void myfunc(char *s) { 2 if (s != NULL) { 3 ... 4 } 5 }
The error occurs on line 2. I cannot find the definition of NULL, but I suspect it is defined like: #define NULL 0
Obviously 0 is signed while s (pointer) is not. Maybe we should use #define NULL (char*)0 instead?
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Monetdb-developers mailing list Monetdb-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-developers
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |

Problem already solved, missed another warning in front. Thanks anyway. On 24-10-2006 10:33:48 +0200, Stefan Manegold wrote:
Just try with both
void myfunc(unsigned char *s) {
and
void myfunc(signed char *s) {
and you find out, whether you compiler be default defines char as signed or unsigned (and whether your systems/compilers header files define NULL as signed or unsigend) ;-)
Stefan
On Tue, Oct 24, 2006 at 10:16:11AM +0200, Fabian Groffen wrote:
I just figured that the following yields in a signed/unsigned warning:
1 void myfunc(char *s) { 2 if (s != NULL) { 3 ... 4 } 5 }
The error occurs on line 2. I cannot find the definition of NULL, but I suspect it is defined like: #define NULL 0
Obviously 0 is signed while s (pointer) is not. Maybe we should use #define NULL (char*)0 instead?
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Monetdb-developers mailing list Monetdb-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-developers
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Monetdb-developers mailing list Monetdb-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-developers
participants (3)
-
Fabian Groffen
-
Sjoerd Mullender
-
Stefan Manegold