Skip to content

glib-compile-resources: Limit string length with -std=c89 and -std=c99

When compiling with -Woverlength-strings, limits of 509 and 4095 bytes are applied to string literals when compiling with C89 or C99 (respectively).

In order to avoid those warnings, fall back to the non-string-literal-based format depending on the C standard in use and the length of the string.

This will unfortunately make compilation slower again for large GResources — it’s essentially a reversion of the string literal improvements for most compilation situations.

That’s an unfortunate necessity, as glib-compile-resources can’t know which compiler is going to be used, or which warning options are going to be passed to it, when the generated C code is compiled.

The way to improve that would be to add an explicit command line argument which allows the string literal limits to be bypassed if you know your compiler can handle it (which most can). This could, for example, be -Wno-overlength-strings, since that’s how you signal to a compiler that you don’t care about string limits.

Signed-off-by: Philip Withnall withnall@endlessm.com

Closes: #1711 (closed)

Merge request reports