SA-MP Forums Archive
[SOLVED]Macro NULL in pawn. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED]Macro NULL in pawn. (/showthread.php?tid=111377)



[SOLVED]Macro NULL in pawn. - -xy! - 01.12.2009

Код:
 error 017: undefined symbol "NULL"
The macro NULL is not included in pawn? Thank you.


Re: Macro NULL in pawn. - Streetplaya - 01.12.2009

you can do

pawn Код:
#define NULL (0)



Re: Macro NULL in pawn. - -xy! - 01.12.2009

Quote:
Originally Posted by MaVe - leeturl.de
you can do

pawn Код:
#define NULL (0)
But defining this way, when I use NULL in some part of the code will not have the same result if I use the conventional NULL because NULL is a null pointer.


Re: Macro NULL in pawn. - Google63 - 01.12.2009

C - ((void*)0)
C++ - (0)

Why did C defined 0 as void pointer ? Because it was used to empty pointer's address.
And by the way, there is not pointers in PAWN because no newbie will be able to learn to use it correct and there it won't be easy(for newbies) to learn.


Re: Macro NULL in pawn. - dice7 - 01.12.2009

Isn't NULL \0 ?


Re: Macro NULL in pawn. - Google63 - 01.12.2009

Quote:
Originally Posted by dice7
Isn't NULL \0 ?
It's called NULL because it's decimal value is (0). NULL on end of string is written like \0 to escape 0 and then it is NULL.

This is totally legal:

new char = 0;

if you do printf("%c", char) it will display nothing. The better example is C/C++ int->char casting.


Re: Macro NULL in pawn. - Streetplaya - 01.12.2009

'\0' == 0 == 0x0 == 1-1 == false == NULL


Re: Macro NULL in pawn. - -xy! - 01.12.2009

Quote:
Originally Posted by JoeBullet
C - ((void*)0)
C++ - (0)

Why did C defined 0 as void pointer ? Because it was used to empty pointer's address.
And by the way, there is not pointers in PAWN because no newbie will be able to learn to use it correct and there it won't be easy(for newbies) to learn.
Thanks JoeBullet, I understood perfectly.
And really, pointers are very boring! But it is not as complicated as many think...

Quote:
Originally Posted by MaVe - leeturl.de
'\0' == 0 == 0x0 == 1-1 == false == NULL
Thanks !

(Sorry my bad english)