msp4th: macro to suppress pointer size cast warnings
authorDan White <dan@whiteaudio.com>
Tue, 14 May 2013 18:16:32 +0000 (13:16 -0500)
committerDan White <dan@whiteaudio.com>
Tue, 14 May 2013 18:30:48 +0000 (13:30 -0500)
msp4th/msp4th.c
msp4th/msp4th.h

index 432ea1519a571020736ab4339913306a8963fe4e..d81ce653553df9b7ec18a696f18d0480c01de15a 100644 (file)
@@ -1380,13 +1380,17 @@ void execN(int16_t opcode)
 
     case 59: // call0  ( &func -- *func() )
       i = TOS;
+GCC_DIAG_OFF(int-to-pointer-cast);
       TOS = (*(int16_t(*)(void)) i) ();
+GCC_DIAG_ON(int-to-pointer-cast);
       break;
 
     case 60: // call1  ( a &func -- *func(a) )
       i = TOS;
       j = NOS;
+GCC_DIAG_OFF(int-to-pointer-cast);
       NOS = (*(int16_t(*)(int16_t)) i) (j);
+GCC_DIAG_ON(int-to-pointer-cast);
       popMathStack();
       break;
 
@@ -1394,7 +1398,9 @@ void execN(int16_t opcode)
       i = TOS;
       j = NOS;
       k = STACK(2);
+GCC_DIAG_OFF(int-to-pointer-cast);
       STACK(2) = (*(int16_t(*)(int16_t, int16_t)) i) (k, j);
+GCC_DIAG_ON(int-to-pointer-cast);
       TOS = 1;
       ndropFunc();
       break;
@@ -1404,7 +1410,9 @@ void execN(int16_t opcode)
       j = NOS;
       k = STACK(2);
       m = STACK(3);
+GCC_DIAG_OFF(int-to-pointer-cast);
       STACK(3) = (*(int16_t(*)(int16_t, int16_t, int16_t)) i) (m, k, j);
+GCC_DIAG_ON(int-to-pointer-cast);
       TOS = 2;
       ndropFunc();
       break;
@@ -1415,7 +1423,9 @@ void execN(int16_t opcode)
       k = STACK(2);
       m = STACK(3);
       n = STACK(4);
+GCC_DIAG_OFF(int-to-pointer-cast);
       STACK(4) = (*(int16_t(*)(int16_t, int16_t, int16_t, int16_t)) i) (n, m, k, j);
+GCC_DIAG_ON(int-to-pointer-cast);
       TOS = 3;
       ndropFunc();
       break;
@@ -1501,7 +1511,9 @@ void execN(int16_t opcode)
 
     case 76: // init  ( &config -- ) \ clears buffers and calls msp4th_init
       *lineBuffer = 0; // if location is same, the call is recursive otherwise
+GCC_DIAG_OFF(int-to-pointer-cast);
       msp4th_init((struct msp4th_config *)popMathStack());
+GCC_DIAG_ON(int-to-pointer-cast);
       break;
 
     case 77: // o2w  ( opcode -- ) \ leaves name of opcode in wordBuffer
index 2abd4f5bb6a695b8176ccf317eb7e30e9c41db8e..7297f41a51ac319c1f5244923aa8d6c7d651bdc3 100644 (file)
@@ -24,4 +24,29 @@ struct msp4th_config {
 void msp4th_init(struct msp4th_config *);
 void msp4th_processLoop(void);
 
+/* Suppress specific warnings (callX words use function pointers)
+ *
+ * from:
+ * Suppressing GCC Warnings, by Patrick Horgan
+ * http://dbp-consulting.com/tutorials/SuppressingGCCWarnings.html
+ */
+
+#if !defined(MSP430) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
+#define GCC_DIAG_STR(s) #s
+#define GCC_DIAG_JOINSTR(x,y) GCC_DIAG_STR(x ## y)
+# define GCC_DIAG_DO_PRAGMA(x) _Pragma (#x)
+# define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x)
+# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
+#  define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(push) \
+        GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W,x))
+#  define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(pop)
+# else
+#  define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W,x))
+#  define GCC_DIAG_ON(x)  GCC_DIAG_PRAGMA(warning GCC_DIAG_JOINSTR(-W,x))
+# endif
+#else
+# define GCC_DIAG_OFF(x)
+# define GCC_DIAG_ON(x)
+#endif
+
 #endif