Skip to content

Commit

Permalink
Fixed bug 4377 - SDL_PIXELFORMAT enum is anonymous, which prevents it…
Browse files Browse the repository at this point in the history
…s use in a templated function

zen3d

While trying to build Pixie lisp (https://github.com/pixie-lang/pixie), which uses SDL for multimedia output, the mandelbrot example won't build. The problem is that internally pixie uses a templated function to dump a value, and gcc chokes because SDL_PIXELFORMAT_RGA8888 is an anonymous enum.

I solved the problem locally by changing from:
   enum {
      SDL_PIXELFORMAT_UNKNOWN,
      ... etc. ...
      SDL_PIXELFORMAT_YUYV = ... etc ...
   };
to:
   typedef enum {
      SDL_PIXELFORMAT_UNKNOWN,
      ... etc. ...
      SDL_PIXELFORMAT_YUYV = ... etc ...
   } SDL_PIXELFORMAT_ENUM;
The net result of this change is that the enum containing SDL_PIXELFORMAT_* is no longer an anonymous enum and can now be used by a templated function.

This local change fixes Pixie lisp for me.

I did notice that you use the idiom
   typedef enum {
      ... etc ...
   } SDL_FOO;
elsewhere in your code, so that change to SDL_PIXELFORMAT doesn't look like it would have a negative impact.
  • Loading branch information
slouken committed Nov 13, 2018
1 parent b815ad5 commit 1a4c0d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/SDL_pixels.h
Expand Up @@ -168,7 +168,7 @@ enum
((format) && (SDL_PIXELFLAG(format) != 1))

/* Note: If you modify this list, update SDL_GetPixelFormatName() */
enum
typedef enum
{
SDL_PIXELFORMAT_UNKNOWN,
SDL_PIXELFORMAT_INDEX1LSB =
Expand Down Expand Up @@ -290,7 +290,7 @@ enum
SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'),
SDL_PIXELFORMAT_EXTERNAL_OES = /**< Android video texture format */
SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ')
};
} SDL_PixelFormatEnum;

typedef struct SDL_Color
{
Expand Down

0 comments on commit 1a4c0d4

Please sign in to comment.