enum str_to_num_flags {
STN_SIGNED = 0x20, // The resulting range is signed
STN_MINUS = 0x40, // Allow optional '-' sign
STN_PLUS = 0x80, // Allow optional '+' sign
STN_TRUNC = 0x100, // Allow range overflow -> truncate to the allowed range
enum str_to_num_flags {
STN_SIGNED = 0x20, // The resulting range is signed
STN_MINUS = 0x40, // Allow optional '-' sign
STN_PLUS = 0x80, // Allow optional '+' sign
STN_TRUNC = 0x100, // Allow range overflow -> truncate to the allowed range
STN_HEX = 0x400, // Support hexadecimal numbers (0x...)
STN_BIN = 0x800, // Support binary numbers (0b...)
STN_OCT = 0x1000, // Support octal numbers (0o...)
STN_HEX = 0x400, // Support hexadecimal numbers (0x...)
STN_BIN = 0x800, // Support binary numbers (0b...)
STN_OCT = 0x1000, // Support octal numbers (0o...)
#define STN_SIGNED_CONVERTOR(type, suffix, usuffix) \
static inline const char *str_to_##suffix(type *num, const char *str, const char **next, const uns flags) \
{ \
#define STN_SIGNED_CONVERTOR(type, suffix, usuffix) \
static inline const char *str_to_##suffix(type *num, const char *str, const char **next, const uns flags) \
{ \
- return str_to_##usuffix((void *) num, str, next, flags | STN_SIGNED); \
+ return str_to_##usuffix((void *) num, str, next, flags | STN_SIGNED | STN_PLUS | STN_MINUS); \