Gamestudio Links
Zorro Links
Newest Posts
What are you working on?
by rayp. 10/15/25 20:44
Help!
by VoroneTZ. 10/14/25 05:04
Zorro 2.70
by jcl. 10/13/25 09:01
ZorroGPT
by TipmyPip. 10/12/25 13:58
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 10/11/25 18:45
Reality Check results on my strategy
by dBc. 10/11/25 06:15
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (Quad, AndrewAMD, TipmyPip, 1 invisible), 6,244 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
joenxxx, Jota, krishna, DrissB, James168
19170 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Displaying pointers with diag statement #469522
11/19/17 15:25
11/19/17 15:25
Joined: Sep 2009
Posts: 1,032
Budapest
Aku_Aku Offline OP
Serious User
Aku_Aku  Offline OP
Serious User

Joined: Sep 2009
Posts: 1,032
Budapest
Hello Community!

I would like to know your opinion this code, i want to display a pointer with diag.
Code:
typedef struct MY_DEF {
  int my_number;
} MY_DEF;
MY_DEF* my_type;
my_type = malloc(sizeof(MY_DEF));
diag(str_printf(str, "nPointer:%d",(long)my_type));


Do you see any problem with this code?

Re: Displaying pointers with diag statement [Re: Aku_Aku] #469524
11/19/17 17:09
11/19/17 17:09
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Online
Senior Expert
Quad  Online
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
normally in C you would do:

Code:
str_printf(str, "nPointer:%p",(void*)my_type)



(notice %p and void* cast)
but i am not sure how lite-c actually handles pointers internally so results may vary.

Edit: you get different results either way depending on whether PRAGMA_POINTER is defined or not.

Last edited by Quad; 11/19/17 17:13.

3333333333
Re: Displaying pointers with diag statement [Re: Quad] #469528
11/19/17 22:46
11/19/17 22:46
Joined: Sep 2009
Posts: 1,032
Budapest
Aku_Aku Offline OP
Serious User
Aku_Aku  Offline OP
Serious User

Joined: Sep 2009
Posts: 1,032
Budapest
Thanks, it seems to me it is better than mine, furthermore p is a regular type in formatting strings.
I tried this format, and finally i will stay with my original type, because (str, "nPointer:%p",(void*)my_type) gives back a hexadecimal number, mine gives back a decimal number.

Last edited by Aku_Aku; 11/19/17 22:53. Reason: final solutions

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