Commit be4fd3d0 authored by Simon McVittie's avatar Simon McVittie

glib-init: statically assert that int is exactly 32 bits long

The GVariant documentation says you can assume that types of no more
than 32 bits may be assumed to be promoted to int by the usual
promotions. If we're going to document that, we should statically
assert that it's true, i.e. sizeof (int) >= sizeof (int32_t).

All reasonable modern platforms are either ILP32 (32-bit platforms),
LP64 (64-bit Linux, *BSD etc.), or LLP64 (64-bit Windows): there have
been ILP64 platforms in the past, but ILP64 has the compelling
disadvantage that {signed char, short, int} can't possibly provide
all of {int8_t, int16_t, int32_t} unless int is 32 bits long.

Bug: Simon McVittie's avatarSimon McVittie <>
Reviewed-by: Colin Walters
parent 52276300
......@@ -101,6 +101,13 @@ debug_key_matches (const gchar *key,
return *key == '\0';
/* The GVariant documentation indirectly says that int is at least 32 bits
* (by saying that b, y, n, q, i, u, h are promoted to int). On any
* reasonable platform, int is in fact *exactly* 32 bits long, because
* otherwise, {signed char, short, int} wouldn't be sufficient to provide
* {int8_t, int16_t, int32_t}. */
G_STATIC_ASSERT (sizeof (int) == sizeof (gint32));
* g_parse_debug_string:
* @string: (allow-none): a list of debug options separated by colons, spaces, or
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment