User forums > Help

NULL undefined

<< < (4/8) > >>

Seronis:
NULLs existance is mentioned in the standard but its use is left open to interpretation. Thus NULL itself is NOT standard.  There is no enforced definition thus no stable use.  So if you are trying to be a no-it-all professional thats fine, as long as you are informative.  But you're being rude and pompous while being wrong.  At least killer's (obvious to everyone but you) opinions ARE being helpful.

TDragon:
Perhaps everyone could just take some time to read and understand the ISO C++ standard. In section 18 (Language support library), subsection 1 (Types), it mandates the existence of a macro, defined in <cstddef>, whose identifier is "NULL" and whose replacement list is implementation-defined. NULL is "standard", folks. The argument of whether or not it's appropriate to be used I'll leave to others, but make sure you have your facts straight.

By the way, this topic has reached the point where it's probably more appropriate for comp.lang.c++, not the Code::Blocks forums. Just a thought.

killerbot:

--- Quote ---In section 18 (Language support library), subsection 1 (Types), it mandates the existence of a macro, defined in <cstddef>, whose identifier is "NULL" and whose replacement list is implementation-defined. NULL is "standard",
--- End quote ---

Ok, that's black on white, and it even says in what header it should be. You convinced me. So people me saying it is not standard is wrong.
Though my arguments on why not to use it still stand. As mentioned, when you read those books, you see those gurus don't use NULL.

Core language and extension libraries make up the standard : that is absolutely correct. I never said the opposite, how else could stl be standard.

[time to fix the spelling mistakes in the names ;-) , Firefox already told me the name was wrong  :P]

And nullptr will be a keyword (check Bjarne's site).

NOTE : wwolf's words are not considered rude by me. He showed me wrong about NULL, it is standard. I made a mistake by believing hints and other suggestions/advices about NULL. As TDragon quoted from the standard, it is obvious.
But as said above, I have put up a some arguments not to use it. It will make things easier.
So let's drop the unprofessional (over)quote of mine. But by not using it, you are professional, since it does not bring you that much benefits, it does bring drawbacks, and as said others also see NULL usage as bad language and the gurus also don't seem to use it. I personally like to follow their coding style and suggestions.

Time to move to 'comp.lang.c++' ;-)

According to TDragon's quote of the standard it should be defined in cstddef, though it seems several compilers also like to define it in other headers through ifndef constructs, let's define it anyway.
Example : TI embedded compiler, the define can be found in : stddef.h/stdio.h/stdlib.h/string.h/time.h.
That means if you did not correctly include cstddef your code might compile because of those other header you might encounter in your include list (perhaps a few levels deeper). But if another compiler did not define it in the header you got lucky wih, your code breaks.
So either always do it through cstddef, or better use '0'.

wwolf:
Killers opinions are bullfeces, trying to stay PC.  IOWs is it all crap. NULL is standard.  If you want, I will get for you a signed paper from Bjarne and Herb. Could you guys please stop this madness??? Youth and its enthusiasm is admirable, but there are times when you just need to learn and live with the facts.  NULL is not perfect, but it is standard.  That is a fact.  The rest is crap.

wwolf:
BTW thanks for not taking my words as an offense. I am not trying to be an S whole... but I have a birth defect. Whatever I say tends to come out is if it used the wrong end... ;)

Anyways, I myself tended to drop NULL in favor of 0 but in live code I have realized that seeing NULL there helps a lot when you are reviewing or integrating the code. A simple text search for NULL will (for example) find all those crappy classes that are doing memory management while they are there to represent application domain concepts. IOWs NULL is a notational convenience that helps the human reader and it helps the text search - when needed.  And I think we all agree that the new nullptr is very welcome. :)

Thanks for clearing it up that the core language solution was the one finally chosen. I have not remembered that decision.

BTW if you do not want to remember (I mean y'all ;) the long URL for the C++ standards site (open-standards.org/something/something) then feel free to use my domain http://stdcpp.org.  I have made it to HTTP redirect to the real site. Easier to remember for me...

WW aka Attila
Ps: Unfortunately I am not really able to (easily) use USENET nowadays. Unfortunately my ISP does not enable access if I am not going from their network. :( So I am not really present on the newsgroups nowadays.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version