Is there integer typedef like size_t for signed values?

Like std::size_t is either 32 or 64 bits wide, depending on compilation, is there an equivalent for signed integers?

Preferably in std namespace.

In windows headers there is LPARAM and LRESULT, is there something similar in the standard?
Last edited on
Thanks, ptrdiff_t is used for pointer arithmentic and array indexing, while this answers my question, I'm concerned that the name of the typedef it self my be misleading to use in operations that don't involve pointer arithmetic and array indexing.

Since I don't really store values larger than 32 bits, it's probably best to use std::int32 and static_cast LRESULT's to std::int32.

then just have a using for a name such as ssize_t to equate to ptrdiff_t

I was hoping to avoid introducing new type name and also to avoid casts.

In the end casting LRESULT or LPARAM is unsafe only if it stores a pointer, so I think I'm going to cast in all other cases.

thanks for help
ssize_t exists in POSIX standard, not C/C++ standard:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html

It's available from <sys/types.h> on Linux/Unix as well as in MinGW on Windows, but apparently not MSVC 🙄

Could do something like this, if you need to support MSVC:
1
2
3
4
5
6
7
#ifdef _MSC_VER 
#ifdef _WIN64
typedef __int64 ssize_t;
#else
typedef int ssize_t;
#endif /* _WIN64 */
#endif /* _MSC_VER */ 
Last edited on
Topic archived. No new replies allowed.