Author Topic: Initialize pointers to NULL in Managers.cpp  (Read 23131 times)

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Initialize pointers to NULL in Managers.cpp
« Reply #15 on: December 13, 2005, 02:21:41 pm »
About NULL pointer, I have found the following FAQ, answer, topic and article rather interesting.

Michael
« Last Edit: December 13, 2005, 02:25:04 pm by Michael »

Offline 280Z28

  • Regular
  • ***
  • Posts: 397
  • *insert unicode here*
Re: Initialize pointers to NULL in Managers.cpp
« Reply #16 on: December 13, 2005, 04:07:17 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" - [email protected]
99 Trans Am, "Daily Driver" - 525rwhp/475rwtq
 Check out The Sam Zone :cool:

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Initialize pointers to NULL in Managers.cpp
« Reply #17 on: December 13, 2005, 04:48:21 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

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Initialize pointers to NULL in Managers.cpp
« Reply #18 on: December 13, 2005, 04:58:04 pm »
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.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Initialize pointers to NULL in Managers.cpp
« Reply #19 on: December 13, 2005, 05:04:48 pm »
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."

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Initialize pointers to NULL in Managers.cpp
« Reply #20 on: December 13, 2005, 05:10:54 pm »
Has anyone of you noticed that wxWidgets uses NULL ?

Is NULL in wxWidgets so defined?

Code
#define NULL 0 

Michael


Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Initialize pointers to NULL in Managers.cpp
« Reply #21 on: December 13, 2005, 05:15:48 pm »
could some admin move this thread to the Offtopics please ...  8)

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Initialize pointers to NULL in Managers.cpp
« Reply #22 on: December 13, 2005, 05:18:17 pm »
Lol, before Rick does that, I have to post this request for feature:

Code
#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."

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Initialize pointers to NULL in Managers.cpp
« Reply #23 on: December 13, 2005, 05:28:18 pm »
Do that again, and I'll rewrite SVN plugin using wxArrays! :P