🔒 Locked
Problem with NULL
Advertisement
Original Post
Well NULL is not a C nor a C++ keyword, so of course you need to define it. Just include stdio, iostream, windows.h and NULL will ultimately be defined...
---
General Programmer at Wildfire Games
working on the 0 A.D. project
---
General Programmer at Wildfire Games
working on the 0 A.D. project
#include any of <clocale>, <cstddef>, <cstdio>, <cstdlib>, <cstring>, <ctime>, <cwchar>.
Or use 0...
"Laughter means distance. Where laughter is absent, madness begins. The moment one takes the world with complete seriousness one is potentially insane. The whole art of learning to live means holding fast to laughter; without laughter the world is a torture chamber, a dark place where dark things will happen to us, a horror show filled with bloody deeds of violence."
-- Jens Bjørneboe
"Laughter means distance. Where laughter is absent, madness begins. The moment one takes the world with complete seriousness one is potentially insane. The whole art of learning to live means holding fast to laughter; without laughter the world is a torture chamber, a dark place where dark things will happen to us, a horror show filled with bloody deeds of violence."
-- Jens Bjørneboe
Your preference is wrong.
NULL has a standard value, according to the C++ standard. But, the implementation is still responsible for defining it in a standard manner. I personally use 0 to indicate null-ness. One might think that NULL helps clarify that it''s actually a null pointer, but in my experience, it doesn''t.
Later,
ZE.
//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links
Later,
ZE.
//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links
Okay, let me start it..... 
Is NULL different than 0?
Techlead
www.myran.com/enilno
Is NULL different than 0?
Techlead
www.myran.com/enilno
quote:Joking, I assume?
Original post by Anonymous Poster
The 0 or NULL argument. Run! Oh... and neither is typesafe.![]()
quote:
Original post by RhoneRanger
Okay, let me start it.....
Is NULL different than 0?
Techlead
www.myran.com/enilno
I don''t beleive NULL is allowed to be anything besides 0, but don''t hold me to that, as it may be up to the implementation to decide. In any compiler/platform I''ve EVER seen, NULL has always been defined as 0.
quote:
Original post by Ready4Dis
[quote]Original post by RhoneRanger
Okay, let me start it.....
Is NULL different than 0?
Techlead
www.myran.com/enilno
I don't beleive NULL is allowed to be anything besides 0, but don't hold me to that, as it may be up to the implementation to decide. In any compiler/platform I've EVER seen, NULL has always been defined as 0.
in the C standard, NULL is (void *)0
in the C++ standard, NULL is 0
When programming in C++, Bjarne says NULL is naughty, stick to trusty 0.
[edited by - Chris- on April 28, 2003 2:31:33 AM]
null is (void*) 0, which is different than just
''0''
''0'' still is a number, while NULL literally nothing!
''0''
''0'' still is a number, while NULL literally nothing!
Quoth Stroustrup:
In C, it has been popular to define a macro NULL to represent the zero pointer. Because of c++''s tighter type checking the use of plain 0, rather than any suggested NULL macro, leads to fewer problems. If you feel you must define NULL, use
const int NULL = 0;
The const qualifier prevents accidental redefinition of NULL and ensures that NULL can be used where a constance is required.
In C, it has been popular to define a macro NULL to represent the zero pointer. Because of c++''s tighter type checking the use of plain 0, rather than any suggested NULL macro, leads to fewer problems. If you feel you must define NULL, use
const int NULL = 0;
The const qualifier prevents accidental redefinition of NULL and ensures that NULL can be used where a constance is required.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement
