
Originally Posted by
javalover
~
Let me just break this down in chronological order here:

Originally Posted by
javalover
I don't think there is a good reason to use uintptr_t when you want to store a pointer.

Originally Posted by
WasserEsser
uintptr_t is the type to choose when your cant use a pointer to a class (for instance if you have none).

Originally Posted by
javalover
Secondly, you may need to use intptr_t instead of uintptr_t when you are working with negative values.

Originally Posted by
WasserEsser
When will your pointers be negative, though?

Originally Posted by
javalover
It has nothing to do with negative pointers. If you care of your numeric value of your pointer (eg. you need to do arithmetics with it and other), then you need to use the correct unsigned or signed type to get for example the correct shift.

Originally Posted by
WasserEsser
Sorry, when will you ever bitshift a pointer to a memory location in a game?
You'll at most add or subtract.

Originally Posted by
javalover
I didn't never talk about negative pointers, I did talk about negative values.

Originally Posted by
WasserEsser
This thread is all about storing the result of a pattern scan, which will result in a pointer to some memory location, be it an entity, a function, an address of a certain instruction or another offset.
These values will not be negative nor will you ever bitshift them.

Originally Posted by
javalover
These values can be negative depending on how you interpret it (signed/unsigned). If you always interpret them as uintptr_t, ofcourse you won't see it is negative, rather you'd see a meaningless value (like 92380493092 instead of a signed -60) - the bitshifting was an example on why sometimes you need to distinguish them. This long discussion about intptr_t/uintptr_t started when you asked me about negative values:
Secondly, you may need to use intptr_t instead of uintptr_t when you are working with negative values

Originally Posted by
javalover
and if he needs that value, he will need to apply an intptr_t or uintptr_t, depending on his context. I'm not going to repeat things. If you want to read my whole answer, good for you, else don't expect another answer from me.
Okay, let me start with these two of your posts:

Originally Posted by
javalover
I don't think there is a good reason to use uintptr_t when you want to store a pointer.

Originally Posted by
javalover
The difference is that the pointers cannot be negative
You said you
don't think there is a good reason to use uintptr_t to store the result of a pattern scan, a function which will return you a
pointer to a
memory location which
can't be negative since it's a
pointer. That doesn't even make sense. The discussion began when you said you don't think it's good to use uintptr_t. Using uintptr_t in this case is
EXACTLY the way to go. Using an intptr_t doesn't make any sense, since, you said it yourself, a pointer can't be negative. Sure, you can use intptr_t to store pointers, but it doesn't make sense to use it over uintptr_t since a pointer can't be negative. On top of that, it can happen that your pointers point to a location over 2GB in RAM, which then breaks your application because your intptr_t is only capable of handling 2 GB instead of 4 GB like uintptr_t is capable of handling ( very
specifically talking about
32 bit here ).
The whole topic here, and my answers were all referring to this, is about storing a pointer returned by a findpattern function. What I was talking about the entire time is that intptr_t is
not to be preffered over uintptr_t.

Originally Posted by
WasserEsser
uintptr_t is the type to choose when your cant use a pointer to a class (for instance if you have none).

Originally Posted by
javalover
Secondly, you may need to use intptr_t instead of uintptr_t when you are working with negative values.

Originally Posted by
WasserEsser
When will your pointers be negative, though?

Originally Posted by
javalover
It has nothing to do with negative pointers. If you care of your numeric value of your pointer (eg. you need to do arithmetics with it and other), then you need to use the correct unsigned or signed type to get for example the correct shift.
As seen above, i was always referring to the topic of storing a pointer. Negative values are not the topic here.
Your arguments are that if you use intptr_t, you can use,
for example, bitshifting.
When working with pointers, you won't use bitshifting, and if you'll ever ever use it, you can just cast your pointer to an integral type.
It can much rather happen that your pointer exceeds the 2 GB boundary than the case that you'll ever want to be able to bitshift your pointers.

Originally Posted by
WasserEsser
This thread is all about storing the result of a pattern scan, which will result in a pointer to some memory location, be it an entity, a function, an address of a certain instruction or another offset.
These values will not be negative nor will you ever bitshift them.

Originally Posted by
javalover
These values can be negative depending on how you interpret it (signed/unsigned). If you always interpret them as uintptr_t, ofcourse you won't see it is negative, rather you'd see a meaningless value (like 92380493092 instead of a signed -60) - the bitshifting was an example on why sometimes you need to distinguish them. This long discussion about intptr_t/uintptr_t started when you asked me about negative values:
Secondly, you may need to use intptr_t instead of uintptr_t when you are working with negative values
and if he needs that value, he will need to apply an intptr_t or uintptr_t, depending on his context. I'm not going to repeat things. If you want to read my whole answer, good for you, else don't expect another answer from me.
Again, you will NOT work with negative values at all since we're working with pointers here. I don't get why you're throwing arguments about negative values in this topic when all we're talking about here are pointers.