ソースを参照

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

while retaining the format string checking.
tags/v0.9.3
Michael Brown 18年前
コミット
b16de6ae66
1個のファイルの変更12行の追加2行の削除
  1. 12
    2
      src/include/compiler.h

+ 12
- 2
src/include/compiler.h ファイルの表示

123
 __asm__ ( ".equ\tDEBUG_LEVEL, " DEBUG_SYMBOL_STR );
123
 __asm__ ( ".equ\tDEBUG_LEVEL, " DEBUG_SYMBOL_STR );
124
 #endif
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
 #define DBG_PRINT(...) printf ( __VA_ARGS__ )
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
 #define DBG  DBG_DISCARD
140
 #define DBG  DBG_DISCARD
131
 #define DBG2 DBG_DISCARD
141
 #define DBG2 DBG_DISCARD

読み込み中…
キャンセル
保存