Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added SDL_VARIABLE_LENGTH_ARRAY so this #ifdef is localized to one pl…
…ace.
  • Loading branch information
icculus committed Dec 6, 2016
1 parent 68d7be3 commit 8b960d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/SDL_internal.h
Expand Up @@ -26,6 +26,15 @@
#define _GNU_SOURCE
#endif

/* This is for a variable-length array at the end of a struct:
struct x { int y; char z[SDL_VARIABLE_LENGTH_ARRAY]; };
Use this because GCC 2 needs different magic than other compilers. */
#if (defined(__GNUC__) && (__GNUC__ <= 2))
#define SDL_VARIABLE_LENGTH_ARRAY 1
#else
#define SDL_VARIABLE_LENGTH_ARRAY
#endif

#include "dynapi/SDL_dynapi.h"

#if SDL_DYNAMIC_API
Expand Down
6 changes: 1 addition & 5 deletions src/audio/SDL_sysaudio.h
Expand Up @@ -105,11 +105,7 @@ typedef struct SDL_AudioDeviceItem
{
void *handle;
struct SDL_AudioDeviceItem *next;
#if (defined(__GNUC__) && (__GNUC__ <= 2))
char name[1]; /* actually variable length. */
#else
char name[];
#endif
char name[SDL_VARIABLE_LENGTH_ARRAY];
} SDL_AudioDeviceItem;


Expand Down

0 comments on commit 8b960d4

Please sign in to comment.