NULL

  • Thread starter Dimitris Kamenopoulos
  • Start date
A

Alexander Terekhov

I

Ivan Vecerina

Hi Alexander!
Alexander Terekhov said:
Ivan Vecerina wrote:
[...]
I have yet to see 00 used to represent an integer value.

http://groups.google.com/[email protected]

The way you always refer to your previous posts amazes me - you
must be owning the depth record of self-referencing NG posts ;)
To quote the relevant few lines:
inline String::String( const String& other )
{
switch ( IntAtomicGet( other.data_->refs ) ) {
case 00: data_ = new StringBuf( *other.data_ ); break;
default: IntAtomicIncrement( (data_ = other.data_)->refs );
} ++nCopies;
}
Reading this, I'd have to ask: why a switch()? and why a 00?
I can guess it is supposed to label non-shareable strings ?
Have you considered using NULL in this case ? said:
00 is mine, end of story.

Well, at least I can show some prior art so far:
http://groups.google.com/[email protected]


Now maybe someone will also show me code that uses a variable
named OO, to make things even more confusing ;)

I admit my "I have yet to see" statement was too daring. I should have
at least included something about "a reasonable motivation to...".
Well, you'll have a better chance with 0p
(but see also my replies in the following thread):
http://google.com/[email protected]

Indeed, a type-safe nil template similar to the one you use in
these examples can be implemented in C++ today.
I guess such a template may make sense all uses of
C-style casts ( i.e. (int*)0 ) have been banned.

Anyway...


Kind regards,
Ivan
 
A

Alexander Terekhov

Ivan Vecerina wrote:
[...]
inline String::String( const String& other )
{
switch ( IntAtomicGet( other.data_->refs ) ) {
case 00: data_ = new StringBuf( *other.data_ ); break;
default: IntAtomicIncrement( (data_ = other.data_)->refs );
} ++nCopies;
}
Reading this, I'd have to ask: why a switch()?

Copy&paste thing, to tell the truth.

http://groups.google.com/[email protected]
and why a 00?

Looks good. Feels better. (WW can confirm ;-) )
I can guess it is supposed to label non-shareable strings ?

Yep.

regards,
alexander.
 
J

jeffc

Noah Roberts said:
Here is an interesting definition I found on the internet:

http://gcc.gnu.org/ml/gcc/1999-03/msg00155.html

/* I prefer this NIL macro to present a NIL pointer than most other
variations that I have seen (eg, NULL, 0, or (cast) 0.
Comme ci, comme ca. - larry gensch
*/
#ifndef NIL
# define NIL(type) (type *) 0
#endif

You can post all the definitions you want. You're missing the point that
they're all non-standard.
 
P

Peter Ammon

Ron said:
What does someValue++ convey to you then?

That someValue is a pointer other than a function pointer or void*, an
arithmetic type, or some type with the postincrement operator overloaded :>

-Peter
 
R

Ron Natalie

Peter Ammon said:
That someValue is a pointer other than a function pointer or void*, an
arithmetic type, or some type with the postincrement operator overloaded :>
So why is this different than someValue = 0?
 
A

Agent Mulder

int a=NULL;
float b=NULL;
etc.
Is that valid?
</>

<Dimitris Kamenopoulos>
NULL is almost certainly defined as
#define NULL 0
So why not? It's just substituted text.
</>

I am reading from Windows 3.1 Guide to Programming, Microsoft Press,
that is both ancient and off-topic, chapter 14, C and Assembly Language:

<Microsoft Windows Guide to Programming>
14.2 Using the NULL Constant

Te symbolic constant NULL has different definitions for Windows and the
Microsoft C Optimizing Compiler (CL). The WINDOWS.H header file
defines NULL as follows:

#define NULL 0

On the other hand, the CL library header files (such as STDDEF.H) define
NULL as follows:

#ifndef NULL
#define NULL ((void *) 0 )
#endif

To avoid compiler warnings, you should use NULL only for pointers and
handles. You should not use NULL for such data types as int and WORD.
</>

-X
 
K

Kevin Goodsell

Agent said:
</>

<Dimitris Kamenopoulos>
NULL is almost certainly defined as
#define NULL 0
So why not? It's just substituted text.
</>

I am reading from Windows 3.1 Guide to Programming, Microsoft Press,
that is both ancient and off-topic, chapter 14, C and Assembly Language:

<Microsoft Windows Guide to Programming>
14.2 Using the NULL Constant

Te symbolic constant NULL has different definitions for Windows and the
Microsoft C Optimizing Compiler

The *C* Optimizing Compiler. Not C++. C++ forbids this form of NULL. C
does not. Even if that were not the case, you can't take the way
Microsoft does things as standard.
#ifndef NULL
#define NULL ((void *) 0 )
#endif

-Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,144
Latest member
KetoBaseReviews
Top