-Wpedantic fixes
authorEthan Lee <flibitijibibo@flibitijibibo.com>
Wed, 01 Apr 2020 12:13:39 -0400
changeset 1235 8fd6c5efe453
parent 1234 608cef8fa24d
child 1236 e2b62a9dde46
-Wpedantic fixes
mojoshader.h
mojoshader_effects.h
--- a/mojoshader.h	Tue Mar 24 21:17:37 2020 -0400
+++ b/mojoshader.h	Wed Apr 01 12:13:39 2020 -0400
@@ -43,6 +43,15 @@
 #endif
 #endif
 
+/* -Wpedantic nameless union/struct silencing */
+#ifndef MOJOSHADERNAMELESS
+#ifdef __GNUC__
+#define MOJOSHADERNAMELESS __extension__
+#else
+#define MOJOSHADERNAMELESS
+#endif /* __GNUC__ */
+#endif /* MOJOSHADERNAMELESS */
+
 /*
  * For determining the version of MojoShader you are using:
  *    const int compiled_against = MOJOSHADER_VERSION;
@@ -87,7 +96,7 @@
     MOJOSHADER_TYPE_PIXEL    = (1 << 0),
     MOJOSHADER_TYPE_VERTEX   = (1 << 1),
     MOJOSHADER_TYPE_GEOMETRY = (1 << 2),  /* (not supported yet.) */
-    MOJOSHADER_TYPE_ANY = 0xFFFFFFFF   /* used for bitmasks */
+    MOJOSHADER_TYPE_ANY = 0x7FFFFFFF   /* used for bitmasks */
 } MOJOSHADER_shaderType;
 
 /*
@@ -104,7 +113,7 @@
     MOJOSHADER_ATTRIBUTE_UINT,
     MOJOSHADER_ATTRIBUTE_FLOAT,
     MOJOSHADER_ATTRIBUTE_DOUBLE,
-    MOJOSHADER_ATTRIBUTE_HALF_FLOAT,  /* MAYBE available in your OpenGL! */
+    MOJOSHADER_ATTRIBUTE_HALF_FLOAT  /* MAYBE available in your OpenGL! */
 } MOJOSHADER_attributeType;
 
 /*
@@ -115,7 +124,7 @@
     MOJOSHADER_UNIFORM_UNKNOWN = -1, /* housekeeping value; never returned. */
     MOJOSHADER_UNIFORM_FLOAT,
     MOJOSHADER_UNIFORM_INT,
-    MOJOSHADER_UNIFORM_BOOL,
+    MOJOSHADER_UNIFORM_BOOL
 } MOJOSHADER_uniformType;
 
 /*
@@ -180,7 +189,7 @@
     MOJOSHADER_SAMPLER_UNKNOWN = -1, /* housekeeping value; never returned. */
     MOJOSHADER_SAMPLER_2D,
     MOJOSHADER_SAMPLER_CUBE,
-    MOJOSHADER_SAMPLER_VOLUME,
+    MOJOSHADER_SAMPLER_VOLUME
 } MOJOSHADER_samplerType;
 
 /*
@@ -432,7 +441,7 @@
     MOJOSHADER_PRESHADEROP_ATAN2_SCALAR,
     MOJOSHADER_PRESHADEROP_DIV_SCALAR,
     MOJOSHADER_PRESHADEROP_DOT_SCALAR,
-    MOJOSHADER_PRESHADEROP_NOISE_SCALAR,
+    MOJOSHADER_PRESHADEROP_NOISE_SCALAR
 } MOJOSHADER_preshaderOpcode;
 
 typedef enum MOJOSHADER_preshaderOperandType
@@ -440,7 +449,7 @@
     MOJOSHADER_PRESHADEROPERAND_INPUT,
     MOJOSHADER_PRESHADEROPERAND_OUTPUT,
     MOJOSHADER_PRESHADEROPERAND_LITERAL,
-    MOJOSHADER_PRESHADEROPERAND_TEMP,
+    MOJOSHADER_PRESHADEROPERAND_TEMP
 } MOJOSHADER_preshaderOperandType;
 
 typedef struct MOJOSHADER_preshaderOperand
@@ -869,10 +878,6 @@
 DECLSPEC void MOJOSHADER_freePreshader(const MOJOSHADER_preshader *preshader);
 
 
-/* Effects interface... */
-#include "mojoshader_effects.h"
-
-
 /* Preprocessor interface... */
 
 /*
@@ -1211,13 +1216,13 @@
     MOJOSHADER_AST_DATATYPE_MATRIX,
     MOJOSHADER_AST_DATATYPE_BUFFER,
     MOJOSHADER_AST_DATATYPE_FUNCTION,
-    MOJOSHADER_AST_DATATYPE_USER,
+    MOJOSHADER_AST_DATATYPE_USER
 } MOJOSHADER_astDataTypeType;
 #define MOJOSHADER_AST_DATATYPE_CONST (1 << 31)
 
 typedef union MOJOSHADER_astDataType MOJOSHADER_astDataType;
 
-// This is just part of DataTypeStruct, never appears outside of it.
+/* This is just part of DataTypeStruct, never appears outside of it. */
 typedef struct MOJOSHADER_astDataTypeStructMember
 {
     const MOJOSHADER_astDataType *datatype;
@@ -1423,7 +1428,7 @@
     MOJOSHADER_AST_IFATTR_IFALL,
     MOJOSHADER_AST_IFATTR_IFANY,
     MOJOSHADER_AST_IFATTR_PREDICATE,
-    MOJOSHADER_AST_IFATTR_PREDICATEBLOCK,
+    MOJOSHADER_AST_IFATTR_PREDICATEBLOCK
 } MOJOSHADER_astIfAttributes;
 
 typedef enum MOJOSHADER_astSwitchAttributes
@@ -2205,7 +2210,7 @@
     MOJOSHADER_irNodeInfo ir;  /* Always MOJOSHADER_IR_MOVE */
     MOJOSHADER_irExpression *dst; /* must result in a temp or mem! */
     MOJOSHADER_irExpression *src;
-    int writemask;  // for write-masking vector channels.
+    int writemask;  /* for write-masking vector channels. */
 } MOJOSHADER_irMove;
 
 typedef struct MOJOSHADER_irExprStmt  /* evaluate expression, throw it away. */
@@ -2218,7 +2223,7 @@
 {
     MOJOSHADER_irNodeInfo ir;  /* Always MOJOSHADER_IR_JUMP */
     int label;
-    // !!! FIXME: possible label list, for further optimization passes.
+    /* !!! FIXME: possible label list, for further optimization passes. */
 } MOJOSHADER_irJump;
 
 typedef struct MOJOSHADER_irCJump  /* conditional jump */
@@ -3302,6 +3307,11 @@
  */
 DECLSPEC const char *MOJOSHADER_mtlGetError(void);
 
+
+/* Effects interface... */
+#include "mojoshader_effects.h"
+
+
 #ifdef __cplusplus
 }
 #endif
--- a/mojoshader_effects.h	Tue Mar 24 21:17:37 2020 -0400
+++ b/mojoshader_effects.h	Wed Apr 01 12:13:39 2020 -0400
@@ -153,7 +153,7 @@
 {
     MOJOSHADER_SHADE_FLAT    = 1,
     MOJOSHADER_SHADE_GOURAUD = 2,
-    MOJOSHADER_SHADE_PHONG   = 3,
+    MOJOSHADER_SHADE_PHONG   = 3
 } MOJOSHADER_shadeMode;
 
 typedef enum MOJOSHADER_blendMode
@@ -230,7 +230,7 @@
     MOJOSHADER_VBF_2WEIGHTS = 2,
     MOJOSHADER_VBF_3WEIGHTS = 3,
     MOJOSHADER_VBF_TWEENING = 255,
-    MOJOSHADER_VBF_0WEIGHTS = 256,
+    MOJOSHADER_VBF_0WEIGHTS = 256
 } MOJOSHADER_vertexBlendFlags;
 
 typedef enum MOJOSHADER_patchedEdgeStyle
@@ -318,7 +318,7 @@
     const char *semantic;
     MOJOSHADER_symbolTypeInfo type;
     unsigned int value_count;
-    union
+    MOJOSHADERNAMELESS union
     {
          /* Raw value types */
         void                           *values;
@@ -407,7 +407,7 @@
     unsigned int *params;
     unsigned int sampler_count;
     MOJOSHADER_samplerStateRegister *samplers;
-    union
+    MOJOSHADERNAMELESS union
     {
         const MOJOSHADER_parseData *shader;
         const MOJOSHADER_preshader *preshader;
@@ -435,7 +435,7 @@
 typedef union MOJOSHADER_effectObject
 {
     MOJOSHADER_symbolType type;
-    union
+    MOJOSHADERNAMELESS union
     {
         MOJOSHADER_effectShader shader;
         MOJOSHADER_effectSamplerMap mapping;
@@ -804,7 +804,6 @@
 /* Metal effect interface... */
 
 typedef struct MOJOSHADER_mtlEffect MOJOSHADER_mtlEffect;
-typedef struct MOJOSHADER_mtlShader MOJOSHADER_mtlShader;
 typedef struct MOJOSHADER_mtlShaderState MOJOSHADER_mtlShaderState;
 
 /* Fully compile/link the shaders found within the effect.