summaryrefslogtreecommitdiff
path: root/vm_debug.h
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-07-28 16:50:26 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-08-06 10:52:00 +0900
commit27173e3735ff509dc8d9cc9b410baff84adf57dc (patch)
tree7b962014a706c970620e1a57b5e4bfacc5acc599 /vm_debug.h
parent58c8b6e86273ccb7a1b903d9ab35956b69b3b1bf (diff)
downloadruby-27173e3735ff509dc8d9cc9b410baff84adf57dc.tar.gz
Allow `RUBY_DEBUG_LOG` format to be empty
GCC warns of empty format strings, perhaps because they have no effects in printf() and there are better ways than sprintf(). However, ruby_debug_log() adds informations other than the format, this warning is not the case.
Diffstat (limited to 'vm_debug.h')
-rw-r--r--vm_debug.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/vm_debug.h b/vm_debug.h
index 5956105648..9c7fc65f7c 100644
--- a/vm_debug.h
+++ b/vm_debug.h
@@ -86,6 +86,15 @@ void ruby_debug_log(const char *file, int line, const char *func_name, const cha
void ruby_debug_log_print(unsigned int n);
bool ruby_debug_log_filter(const char *func_name, const char *file_name);
+#if RBIMPL_COMPILER_IS(GCC) && defined(__OPTIMIZE__)
+# define ruby_debug_log(...) \
+ RB_GNUC_EXTENSION_BLOCK( \
+ RBIMPL_WARNING_PUSH(); \
+ RBIMPL_WARNING_IGNORED(-Wformat-zero-length); \
+ ruby_debug_log(__VA_ARGS__); \
+ RBIMPL_WARNING_POP())
+#endif
+
// convenient macro to log even if the USE_RUBY_DEBUG_LOG macro is not specified.
// You can use this macro for temporary usage (you should not commit it).
#define _RUBY_DEBUG_LOG(...) ruby_debug_log(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, "" __VA_ARGS__)