memoryformat: Copy idea from tiff code
authorBenjamin Otte <otte@redhat.com>
Fri, 21 Jul 2023 01:05:40 +0000 (03:05 +0200)
committerBenjamin Otte <otte@redhat.com>
Fri, 21 Jul 2023 23:33:44 +0000 (01:33 +0200)
The static assertion makes sure that newer formats get added.

gdk/gdkmemoryformat.c

index 9c85ae2575e69f997bc9d1caf7cbd8fc3404ab6c..40fea6987e9d196ce1a2743ced9b3ead07f85af6 100644 (file)
@@ -346,7 +346,7 @@ struct _GdkMemoryFormatDescription
 #  error "Define the right GL flags here"
 #endif
 
-static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
+static const GdkMemoryFormatDescription memory_formats[] = {
   [GDK_MEMORY_B8G8R8A8_PREMULTIPLIED] = {
     GDK_MEMORY_ALPHA_PREMULTIPLIED,
     4,
@@ -629,6 +629,9 @@ static const GdkMemoryFormatDescription memory_formats[GDK_MEMORY_N_FORMATS] = {
   }
 };
 
+/* if this fails, somebody forgot to add formats above */
+G_STATIC_ASSERT (G_N_ELEMENTS (memory_formats) == GDK_MEMORY_N_FORMATS);
+
 gsize
 gdk_memory_format_bytes_per_pixel (GdkMemoryFormat format)
 {