Am Freitag, 19. Oktober 2007 23:18:51 schrieb Ken Thomases:
This makes the test test the proper thing on Mac OS X. It still fails, but for a good reason.
configure.ac | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
- char *name=NULL;
- char *name=0;
Shouldn't that be (void *) 0 or (char *) 0?
On Oct 19, 2007, at 5:24 PM, Stefan Dösinger wrote:
Am Freitag, 19. Oktober 2007 23:18:51 schrieb Ken Thomases:
This makes the test test the proper thing on Mac OS X. It still fails, but for a good reason.
configure.ac | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
- char *name=NULL;
- char *name=0;
Shouldn't that be (void *) 0 or (char *) 0?
I don't think that's necessary. It compiled without warning here, even with -Wall. Doesn't the C standard says that 0 casts to a pointer naturally? Maybe that's C++.
-Ken
Ken Thomases wrote:
On Oct 19, 2007, at 5:24 PM, Stefan Dösinger wrote:
Am Freitag, 19. Oktober 2007 23:18:51 schrieb Ken Thomases:
This makes the test test the proper thing on Mac OS X. It still fails, but for a good reason.
configure.ac | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
- char *name=NULL;
- char *name=0;
Shouldn't that be (void *) 0 or (char *) 0?
I don't think that's necessary. It compiled without warning here, even with -Wall. Doesn't the C standard says that 0 casts to a
Actually it's not a cast. It's a heuristic that the compiler has to make to detect a NULL pointer. The best heuristic for this is (char *) 0. This is a limitation of the C language to not have NULL as integral part of the language.
pointer naturally? Maybe that's C++.
bye michael
Michael Stefaniuc mstefani@redhat.com writes:
Actually it's not a cast. It's a heuristic that the compiler has to make to detect a NULL pointer. The best heuristic for this is (char *) 0.
There's no heuristic involved here, the assignment is clearly to a pointer, and 0 is a perfectly valid null pointer, no cast is needed.
Alexandre Julliard wrote:
Michael Stefaniuc mstefani@redhat.com writes:
Actually it's not a cast. It's a heuristic that the compiler has to make to detect a NULL pointer. The best heuristic for this is (char *) 0.
Duh ... that should have been (void *) 0.
There's no heuristic involved here, the assignment is clearly to a pointer, and 0 is a perfectly valid null pointer, no cast is needed.
I was talking more in general and not about this concrete case here. Both "0" and "(void *) 0" work here; which to use is a matter of style and thus good for a flame war. But i don't care too much to start one ;)
bye michael
Both "0" and "(void *) 0" work here; which to use is a matter of style and thus good for a flame war. But i don't care too much to start one ;)
I'll point out that for the case at hand, a configure test, code readability is probably not a very important goal. As Ken points out, the configure check failed before, but for the wrong reason - NULL wasn't defined. Now it'll fail for the right reason - the function doesn't exist on MacOS X. The compiler warning during the configure check is only apparent in the configure log, which is probably why the reason for this failing was missed for so long.
--Juan
On Sat, Oct 20, 2007 at 11:12:10AM +0200, Alexandre Julliard wrote:
Michael Stefaniuc mstefani@redhat.com writes:
Actually it's not a cast. It's a heuristic that the compiler has to make to detect a NULL pointer. The best heuristic for this is (char *) 0.
(char *)0 is bad, 0 is ok, as is (void *)0
There's no heuristic involved here, the assignment is clearly to a pointer, and 0 is a perfectly valid null pointer, no cast is needed.
As is 1-1, or any other compile time integer expression with a numeric vaule of zero.
David
Am Samstag, 20. Oktober 2007 00:36:13 schrieb Ken Thomases:
On Oct 19, 2007, at 5:24 PM, Stefan Dösinger wrote:
Am Freitag, 19. Oktober 2007 23:18:51 schrieb Ken Thomases:
This makes the test test the proper thing on Mac OS X. It still fails, but for a good reason.
configure.ac | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
- char *name=NULL;
- char *name=0;
Shouldn't that be (void *) 0 or (char *) 0?
I don't think that's necessary. It compiled without warning here, even with -Wall. Doesn't the C standard says that 0 casts to a pointer naturally? Maybe that's C++.
I think with -pedantic it warns about that. It could be gcc version dependent too.