Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

string format for intptr_t and uintptr_t

What is the string format for intptr_t and uintptr_t which is valid for both the 32 and 64 bit architecture .

EDIT

warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has type "AAA" 

This is the warning i am getting in 64 bit but not in 32 bit.

  intptr_t  AAA 
like image 970
thetna Avatar asked Apr 26 '11 20:04

thetna


People also ask

What type is Uintptr_t?

uintptr_t is an unsigned integer type that is capable of storing a data pointer (whether it can hold a function pointer is unspecified). Which typically means that it's the same size as a pointer.

What does the format string %if stands for?

"printf" is the name of one of the main C output functions, and stands for "print formatted". printf format strings are complementary to scanf format strings, which provide formatted input (lexing aka. parsing).


1 Answers

That would be the following macros from inttypes.h:

For printf: PRIdPTR PRIiPTR PRIoPTR PRIuPTR PRIxPTR PRIXPTR

For scanf: SCNdPTR SCNiPTR SCNoPTR SCNuPTR SCNxPTR

Usage example:

uintptr_t p = SOME_VALUE; printf("Here's a pointer for you: %" PRIxPTR "\n", p); 
like image 105
ninjalj Avatar answered Sep 27 '22 16:09

ninjalj