Message Board
Message Board > Fenix / Bennu / Gemix / DIV > NULL??? |
July 24, 2007, 10:28 | |
Quiest
now with more happynes 142 posts |
How the hell can I NULL my pointers in Fenix? I want a linked list, but I have no idea how to check if a pointer points at something or not, because I can`t set it to NULL 0 doesn't work either... The wiki says: Available since Fenix 0.93. o.O There is a 0.93 yet? What can I do in 0.84? I don`t wanna use a counter for the size of the list... [Edited on July 24, 2007 by Quiest] ____________ Roundhousekick to the face, baby! |
# |
July 24, 2007, 13:12 | |
Dennis
どこかにいる 2092 posts |
I have 0.93. First I had 0.92a, by simply replacing the fxi and fxc by a newer one you'll have 0.93. edit: try this [Edited on July 24, 2007 by Dennis] ____________ Kwakkel |
# |
July 24, 2007, 14:07 | |
Quiest
now with more happynes 142 posts |
Thanks. I didn`t know there already is a 0.93. I still need a better way to do this in 0.84. [Edited on July 24, 2007 by Quiest] ____________ Roundhousekick to the face, baby! |
# |
July 24, 2007, 23:29 | |
Sandman
F3n!x0r 1194 posts |
Code: Global int pointer nullintpointer; word pointer nullwordpointer; byte pointer nullbytepointer; End By default the values are 0, so you can use these as nullpointers. In later Fenix versions and in Bennu, null is indeed added, I can assure you (I requested it ). [EDIT] You could also use: [code] memset(&my_pointer,0,sizeof(pointer)); [Edited on July 24, 2007 by Sandman] ____________ BennuWiki Yes, my avatar has grey borders in IE (so get a decent browser) ROOFLEZ ROOFLEZ |
# |
July 25, 2007, 09:35 | |
Quiest
now with more happynes 142 posts |
Thanks Sandman I wish I could join #bilge again from time to time, but my damn internet is off the line at home for about three weeks now ____________ Roundhousekick to the face, baby! |
# |
July 25, 2007, 09:55 | |
PEader
お前はもう死んでいる 1486 posts |
Couldn't you define your own constant NUll = 0 and use that?
____________ I see 57,005 people. |
# |
July 25, 2007, 14:37 | |
Quiest
now with more happynes 142 posts |
Quoting Quiest: ...
0 doesn't work either... ... ____________ Roundhousekick to the face, baby! |
# |
July 26, 2007, 09:40 | |
Dennis
どこかにいる 2092 posts |
I don't think Peader means the number 0 itself, but the constant. That is different than just typing 0, innit? Since it has some memory allocated...
____________ Kwakkel |
# |
July 26, 2007, 16:28 | |
Quiest
now with more happynes 142 posts |
In C atleast, if you do a #define NULL 0 the word NULL would just be replaced by 0 by the compiler, I think, so it would not make much of a difference. Should be same with const NULL = 0; in Fenix. ____________ Roundhousekick to the face, baby! |
# |
July 26, 2007, 20:16 | |
Sandman
F3n!x0r 1194 posts |
Fenix: Code: Const NULL = 0; End C: Code: const char * NULL = '\0'; Fenix: Code: #define NULL 0 C: Code: #define NULL 0 Also, I thought this would compile in 0.84a: Code: Private int pointer my_pointer; Begin my_pointer = 0; End I also thought if(my_pointer) would check whether my_pointer is NULL or not. ____________ BennuWiki Yes, my avatar has grey borders in IE (so get a decent browser) ROOFLEZ ROOFLEZ |
# |
July 27, 2007, 11:56 | |
Quiest
now with more happynes 142 posts |
It gave me an "incompatible type" error. [Edited on July 27, 2007 by Quiest] ____________ Roundhousekick to the face, baby! |
# |
July 27, 2007, 13:36 | |
Dennis
どこかにいる 2092 posts |
Quoting Quiest: In C atleast, if you do a #define NULL 0 the word NULL would just be replaced by 0 by the compiler, I think, so it would not make much of a difference. Should be same with const NULL = 0; in Fenix. Yes You'll have to do: my_pointer = &NULL; which is almost the same solution as Sandman's. Sandman's solution is better, because you point to nothing (you haven't reserved memory) and here you have the constant whose memory is automatically allocated. [Edited on July 27, 2007 by Dennis] ____________ Kwakkel |
# |
August 2, 2007, 22:44 | |
Eckolin
Quite Whiskered 388 posts |
Have you tried Code: if (pointername) // Things happen when the pointer is defined end ? ____________ Maker of Games... Wisdom is supreme; therefore get wisdom. Need help with coding? I probably wrote something similar. |
# |
August 7, 2007, 17:28 | |
Quiest
now with more happynes 142 posts |
I dont think I have... but the pointer should still point to an adress, even if there is nothing there anymore.
____________ Roundhousekick to the face, baby! |
# |
August 7, 2007, 21:08 | |
Eckolin
Quite Whiskered 388 posts |
I just used =0 and it compiled. :/ Code: program demonstration; global int pointer tis; begin if (tis) // Oughtn't be. say("Worse than failure."); return; end tis=alloc(100); if (tis) say("This's'st should be (pass one)"); else say("Shuddah'n (fail)"); return; end free(tis); tis=0; if (tis) say("No such luck."); return; else say("Victory is ours."); end end [Edited on August 7, 2007 by Eckolin] ____________ Maker of Games... Wisdom is supreme; therefore get wisdom. Need help with coding? I probably wrote something similar. |
# |
Message Board > Fenix / Bennu / Gemix / DIV > NULL???