I found that in C99 you should #include <stdint.h>
and that seems to work with my C++03 gcc compiler too, but is that the right header for modern C++, is it portable?
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. It is optionally defined in C++11 and later standards.
intptr_t is a signed integer memsize-type that can safely store a pointer regardless of the platform capacity. The type intptr_t is similar to the types ptrdiff_t and INT_PTR. The size of the type depends upon the data model.
It's an unsigned integer type exactly the size of a pointer. Whenever you need to do something unusual with a pointer - like for example invert all bits (don't ask why) you cast it to uintptr_tand manipulate it as a usual integer number, then cast back.
It will define uintptr_t in the global namespace, but not namespace std. You can expect all standard headers that end in .h to be namespace-unaware. Thanks Drew, I had missed that. @DrewDormann - they aren't necessarily unaware of namespaces.
} Cbindgen should itself include inttypes.h (and all other relevant types) for allow C language emitted headers to work. Hmmm, which c compiler / library are you using?
5 Answers 5 ActiveOldestVotes 274 First thing, at the time the question was asked, uintptr_twas not in C++. It's in C99, in <stdint.h>, as an optional type. Many C++03 compilers do provide that file. It's also in C++11, in <cstdint>, where again it is optional, and which refers to C99 for the definition.
In C++11, it's in <cstdint>
.
In older versions of the language, it didn't officially exist; but many compilers provided the C99 library as an extension, in which case it would be available in <stdint.h>
.
It is defined in stdint.h:
#include <stdint.h>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With