POV-Ray : Newsgroups : povray.off-topic : Quick C language-lawyer question... : Re: Quick C language-lawyer question... Server Time
5 Sep 2024 17:11:50 EDT (-0400)
  Re: Quick C language-lawyer question...  
From: Darren New
Date: 30 Jul 2009 23:44:07
Message: <4a726887$1@news.povray.org>
clipka wrote:
> Darren New <dne### [at] sanrrcom> wrote:
>> People often mistakenly argue that C++ guarantees the bit pattern is
>> zero because you now write { char* x = 0; } instead of { char* x = NULL; }
> 
> BTW, those are perfectly identical according to the C99 spec: NULL *is* either
> defined as the numeric literal 0, or the very same cast to void*.

I know that. I was under the impression that C++ got rid of the possibility 
of it being a cast, and strongly suggested people just use the literal 0.

> People forget though that char* x = 0 actually involves an implicit typecast -
> just like they forget (or never learn in the first place) that a typecast in C
> does *not* necessarily preserve the binary representation...

Yes. Well of course { float f = 2; } involves a change in the 
representation. A lot of people also forget that pointers to functions have 
different rules from pointers to data (like, you can't cast them to void* 
reliably).

-- 
   Darren New, San Diego CA, USA (PST)
   "We'd like you to back-port all the changes in 2.0
    back to version 1.0."
   "We've done that already. We call it 2.0."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.