PDA

View Full Version : glintptr?



Mars_999
11-13-2006, 01:19 PM
What is this data type?

intptr

It's on the new extension ext_bindable_uniform and I can't find what GL data type this is supposed to be. Thanks

ZbuffeR
11-13-2006, 01:33 PM
naively, I would guess :

typedef *int GLintptr;

Mars_999
11-13-2006, 04:40 PM
I would to ZbuffeR but MSVC shows typedef ptrdiff_t

I have never seen that before...

Mars_999
11-13-2006, 04:42 PM
Well here is the lowd down.


C and C++ define a special type for pointer arithmetic, namely ptrdiff_t, which is a typedef of a platform-specific signed integral type. You can use a variable of type ptrdiff_t to store the result of subtracting and adding pointers. For example:


#include <stdlib.h>
int main()
{
int buff[4];
ptrdiff_t diff = (&buff[3]) - buff; // diff = 3
diff = buff -(&buff[3]); // -3
}

What are the advantages of using ptrdiff_t? First, the name ptrdiff_t is self-documenting and helps the reader understand that the variable is used in pointer arithmetic exclusively. Secondly, ptrdiff_t is portable: its underlying type may vary across platforms, but you don't need to make changes in the code when porting it.

ZbuffeR
11-14-2006, 12:15 AM
Thanks for the clarifications.