Added SDL_VARIABLE_LENGTH_ARRAY so this #ifdef is localized to one place.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 06 Dec 2016 02:20:58 -0500
changeset 10680fe759a74b018
parent 10679 a458fc3377dc
child 10681 34b25c97b17f
Added SDL_VARIABLE_LENGTH_ARRAY so this #ifdef is localized to one place.
src/SDL_internal.h
src/audio/SDL_sysaudio.h
     1.1 --- a/src/SDL_internal.h	Tue Dec 06 00:40:09 2016 -0800
     1.2 +++ b/src/SDL_internal.h	Tue Dec 06 02:20:58 2016 -0500
     1.3 @@ -26,6 +26,15 @@
     1.4  #define _GNU_SOURCE
     1.5  #endif
     1.6  
     1.7 +/* This is for a variable-length array at the end of a struct:
     1.8 +    struct x { int y; char z[SDL_VARIABLE_LENGTH_ARRAY]; };
     1.9 +   Use this because GCC 2 needs different magic than other compilers. */
    1.10 +#if (defined(__GNUC__) && (__GNUC__ <= 2))
    1.11 +#define SDL_VARIABLE_LENGTH_ARRAY 1
    1.12 +#else
    1.13 +#define SDL_VARIABLE_LENGTH_ARRAY
    1.14 +#endif
    1.15 +
    1.16  #include "dynapi/SDL_dynapi.h"
    1.17  
    1.18  #if SDL_DYNAMIC_API
     2.1 --- a/src/audio/SDL_sysaudio.h	Tue Dec 06 00:40:09 2016 -0800
     2.2 +++ b/src/audio/SDL_sysaudio.h	Tue Dec 06 02:20:58 2016 -0500
     2.3 @@ -105,11 +105,7 @@
     2.4  {
     2.5      void *handle;
     2.6      struct SDL_AudioDeviceItem *next;
     2.7 -    #if (defined(__GNUC__) && (__GNUC__ <= 2))
     2.8 -    char name[1];  /* actually variable length. */
     2.9 -    #else
    2.10 -    char name[];
    2.11 -    #endif
    2.12 +    char name[SDL_VARIABLE_LENGTH_ARRAY];
    2.13  } SDL_AudioDeviceItem;
    2.14  
    2.15