News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Initialize pointers to NULL in Managers.cpp

Started by 280Z28, December 12, 2005, 11:24:06 PM

Previous topic - Next topic

Michael

#15
About NULL pointer, I have found the following FAQ, answer, topic and article rather interesting.

Michael
[url="http://img207.imageshack.us/img207/9728/411948picture4em.png"]http://img207.imageshack.us/img207/9728/411948picture4em.png[/url]

280Z28

Quote from: Michael on December 13, 2005, 02:21:41 PM
About NULL pointer, I have found the following FAQ, answer, topic and article rather interesting.

Michael


I agree that 0 looks like an integer and NULL distinguishes pointer initialization from integer initialization. On that basis alone I will always have state to use NULL for pointers in my style guidelines for any project I create. I'm also a grown up, so if I know that someone else's guidelines specify something different, I will follow them with the same respect I would expect them to treat my rules with if they were helping on my projects.
78 280Z, "a few bolt-ons" - 12.71@109.04
99 Trans Am, "Daily Driver" - 525rwhp/475rwtq
Check out The Sam Zone :cool:

Michael

Quote from: 280Z28 on December 13, 2005, 04:07:17 PM
I agree that 0 looks like an integer and NULL distinguishes pointer initialization from integer initialization. On that basis alone I will always have state to use NULL for pointers in my style guidelines for any project I create. I'm also a grown up, so if I know that someone else's guidelines specify something different, I will follow them with the same respect I would expect them to treat my rules with if they were helping on my projects.

I used NULL at the beginning as I thought it was better than 0, but switched to 0 when I discovered that it was not. In the project, I am actually working, several partners used 0 instead of  NULL. Discussing with them about that was really interesting. However, you should never accept blindly ideas, suggestions, etc. from other persons without first thinking by yourself. This is something, I have learnt.

Michael
[url="http://img207.imageshack.us/img207/9728/411948picture4em.png"]http://img207.imageshack.us/img207/9728/411948picture4em.png[/url]

rickg22

Has anyone of you noticed that wxWidgets uses NULL ?

Since C::B is a wxWidgets project, i prefer to follow the convention and use NULL. If anybody thinks of a specific situation where i MUST use 0 instead, please do so.

thomas

wxWidgets also does stuff like redefining global operator new. Should we do things like that too?
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Michael

Quote from: rickg22 on December 13, 2005, 04:58:04 PM
Has anyone of you noticed that wxWidgets uses NULL ?

Is NULL in wxWidgets so defined?


#define NULL 0


Michael

[url="http://img207.imageshack.us/img207/9728/411948picture4em.png"]http://img207.imageshack.us/img207/9728/411948picture4em.png[/url]

tiwag

could some admin move this thread to the Offtopics please ...  8)

thomas

Lol, before Rick does that, I have to post this request for feature:

#define if(x,y) while(x){(y) break;}

:lol:
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

rickg22

Do that again, and I'll rewrite SVN plugin using wxArrays! :P