[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: c++ and NULL
From: srosa () afterburner ! neu ! sgi ! com (Stephane Rosa (Stephen))
Date: 1997-07-31 10:09:14
[Download RAW message or body]
******************************
On Jul 30, 9:42pm, Claus Riemann wrote:
> Subject: Re: c++ and NULL
> M G Berberich wrote:
> >
> > Hello,
> >[...]
> > It causes problems on every machine where NULL is not equal to int. On
> > 64-bit machines NULL often is long because a pointer is 64 bit. In
>
> And what is the real problem with it?
> Are there people using 'int i = NULL'? :-)
> Seriously: What should people use instead of following code?
>
> FILE *fd = fopen(...);
> if (fd) ...
>
> Do you think 'if (fd == NULL) ...' is much better/portable?
>
> Without a good example the statement 'Don't use NULL' is
> a non believable insinuation.
> The only code which comes into my mind is:
>
> class foo {
> foo(int){}
> foo(char*){}
> } ;
> #define NULL 0L // DON'T do this in real!! :-)
> main () {
> foo(NULL);
> }
>
> When compling this on a SGI you will receive the error
> ... more than one instance of constructor "foo::foo"
> matches the argument list:
> function "foo::foo(int)"
> function "foo::foo(char *)"
> foo(NULL);
<$0.002>
Out of topic, but the workaround is to write foo( (int) NULL); or foo( (char *) NULL);
to fix that on SGI. Ugly like hell, but it works...
</$0.002>
>
> But that is not the problem you mean, right?
>
> --cla
>
> P.S.: Just my 2 cents...
>
> **********************************************************
> German National Research Center for Information Technology
> Claus Riemann (IMK.VMSD) Phone: (+49 2241) 14-2865
> Schloss Birlinghoven Fax: (+49 2241) 14-2040
> 53754 Sankt Augustin Don't dream it - Be it!
>-- End of excerpt from Claus Riemann
******************************
--
####################################################
SILICON GRAPHICS EUROPEAN NETWORK OPERATIONS CENTER
####################################################
Stephane Rosa NOC : +41 (0)32 843-3592
Silicon Graphics Fax : +41 (0)32 843-3909
ENOC Administrator Tel : +41 (0)32 843-3638
GSM : +41 (0)79 448-5335
SMTP : srosa@neu.sgi.com
HTML : http://www.sgi.com
IRC : Clipper on #geneva
====================================================
"Problems never exist, there are
only pending solutions"
Myself
====================================================
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic