Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by k_ivan. 04/25/26 19:13
ZorroGPT
by TipmyPip. 04/25/26 16:09
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
400 free seamless texture pack downl. here !
by NeoDumont. 04/08/26 19:55
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (Quad), 3,790 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
valino, juergenwue, VladMak, Geir, ondrej
19209 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Pointer confusion? [Re: DJBMASTER] #299433
11/23/09 23:52
11/23/09 23:52
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
OK Im a little lost then.

Looking at your code
Code:
var sound_handle = 0; // variable sound handle
var* pnt_to_sound; // pointer to handle

function TestPointer()
{
   if(pnt_to_sound == NULL)
   {
      error("Null Pointer!");
   }
}

void main()
{
   pnt_to_sound =  &sound_handle;
   on_space = TestPointer;
}


Exactly like this, should the message be triggered?

That is, is TestPointer supposed to test if pnt_to_sound==zero (not pointing at anything),
or is it supposed to test if sound_handle(via pnt_to_snd)==zero ?


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Pointer confusion? [Re: EvilSOB] #299436
11/24/09 00:27
11/24/09 00:27
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline OP
Serious User
DJBMASTER  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
ok, this is my initial definition...
Code:
var sound_handle = 0; // variable sound handle
var* pnt_to_sound = &sound_handle; // pointer to handle


And so the pointer is assigned the memory address of the variable. Yet if I am to do if(pnt_to_sound == NULL) it will evaluate to true.

Re: Pointer confusion? [Re: DJBMASTER] #299437
11/24/09 00:54
11/24/09 00:54
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Ah, I get it now... but ..erm... I dunno.

Logically it should work.
I think it works in real C.
Ive found it sometimes works in lite-c, but cant see a pattern to its failures.

So Im now going to be watching this thread for an answer too.
FYI, my existing workaround goes something like this...
Code:
var* pnt_to_sound;   void pnt_to_sound_startup() { pnt_to_sound = &sound_handle; }




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1