[PATCH weston] gl: Don't declare variables in for loop

Bryce Harrington bryce at osg.samsung.com
Mon Nov 21 19:05:36 UTC 2016


On Mon, Nov 21, 2016 at 06:06:23PM +0000, Daniel Stone wrote:
> Hi,
>
> On 21 November 2016 at 18:02, Bryce Harrington <bryce at osg.samsung.com> wrote:
> > Fixes compilation error introduced by 43cea54c:
> >
> >   libweston/gl-renderer.c:2862:2: error: ‘for’ loop initial declarations
> >   are only allowed in C99 mode
> >     for (unsigned i = 0; i < ARRAY_LENGTH(swap_damage_ext_to_entrypoint);
> >     i++) {
> >     ^
>
> Sorry, no idea how I didn't spot that during review. Out of interest,
> what exotic compiler/CFLAGS are you using to have caught this?

Nothing particularly fancy, I think most of this is just stock compiler
settings for my distro:

GCC_CFLAGS='-Wall -Wextra -Wno-unused-parameter -Wno-shift-negative-value -Wno-missing-field-initializers \
	-g -fvisibility=hidden -Wstrict-prototypes -Wmissing-prototypes -Wsign-compare'

Here's the full warning for context:

  CCLD     libweston-desktop-2.la
  CC       libweston/gl_renderer_la-gl-renderer.lo
libweston/gl-renderer.c: In function ‘gl_renderer_setup_egl_extensions’:
libweston/gl-renderer.c:2862:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
  for (unsigned i = 0; i < ARRAY_LENGTH(swap_damage_ext_to_entrypoint); i++) {
  ^
libweston/gl-renderer.c:2862:2: note: use option -std=c99 or -std=gnu99 to compile your code
libweston/gl-renderer.c: At top level:
cc1: warning: unrecognized command line option "-Wno-shift-negative-value" [enabled by default]
make[1]: *** [libweston/gl_renderer_la-gl-renderer.lo] Error 1
make[1]: Leaving directory `/home/bryce/src/Wayland/weston'
make: *** [all] Error 2

So, looks more like -std=c99 just isn't set by default by the compiler
on my system (which it shouldn't be, for wayland anyway.)  I'm running
gcc 4.8.4 which is on the old side; perhaps things have changed wrt c99
defaults used with newer compilers?

I haven't sorted out the -Wno-shift-negative-value warning but
suspecting it's bogus.

> Pushed
> with review in any case:
> To ssh://git.freedesktop.org/git/wayland/weston
>    3447619..fe0410b  upstream -> master

Thanks for reviewing and pushing,
Bryce

> Cheers,
> Daniel


More information about the wayland-devel mailing list