Browse Source

Inhibit compiler warnings on DBG() when building a non-debug object,

while retaining the format string checking.
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
b16de6ae66
1 changed files with 12 additions and 2 deletions
  1. 12
    2
      src/include/compiler.h

+ 12
- 2
src/include/compiler.h View File

@@ -123,9 +123,19 @@ __asm__ ( ".equ\t" OBJECT_SYMBOL_STR ", 0" );
123 123
 __asm__ ( ".equ\tDEBUG_LEVEL, " DEBUG_SYMBOL_STR );
124 124
 #endif
125 125
 
126
+/** Do not print
127
+ *
128
+ * This function is used only for printf()-style format string
129
+ * checking.  The function body does not exist, and no reference to it
130
+ * should ever appear in any compiled object.
131
+ */
132
+extern int __attribute__ (( format ( printf, 1, 2 ) ))
133
+__do_not_printf ( const char *fmt, ... );
134
+
126 135
 #define DBG_PRINT(...) printf ( __VA_ARGS__ )
127
-#define DBG_DISCARD(...) do { if ( 0 ) printf ( __VA_ARGS__ ); } while ( 0 )
128
-/*#define DBG_DISCARD(...) do {} while ( 0 )*/
136
+#define DBG_DISCARD(...) do {					\
137
+		if ( 0 ) __do_not_printf ( __VA_ARGS__ );	\
138
+	} while ( 0 )
129 139
 
130 140
 #define DBG  DBG_DISCARD
131 141
 #define DBG2 DBG_DISCARD

Loading…
Cancel
Save