From 5317b7d0c2c45d881cc17299204b994890564d5f Mon Sep 17 00:00:00 2001 From: erwin coumans Date: Mon, 3 Jun 2013 15:39:47 -0700 Subject: [PATCH] add do-while to logging functions, to avoid errors in user code: if b3Error("msg"); else {...} would fail before --- src/Bullet3Common/b3Logging.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Bullet3Common/b3Logging.h b/src/Bullet3Common/b3Logging.h index 9be0b6df3..a366c58c6 100644 --- a/src/Bullet3Common/b3Logging.h +++ b/src/Bullet3Common/b3Logging.h @@ -17,14 +17,15 @@ void b3OutputPrintfVarArgsInternal(const char *str, ...); void b3OutputWarningMessageVarArgsInternal(const char *str, ...); void b3OutputErrorMessageVarArgsInternal(const char *str, ...); +///We add the do/while so that the statement "if (condition) b3Printf("test"); else {...}" would fail ///You can also customize the message by uncommenting out a different line below #define b3Printf(...) b3OutputPrintfVarArgsInternal(__VA_ARGS__) -//#define b3Printf(...) {b3OutputPrintfVarArgsInternal("b3Printf[%s,%d]:",__FILE__,__LINE__);b3OutputPrintfVarArgsInternal(__VA_ARGS__); } +//#define b3Printf(...) do {b3OutputPrintfVarArgsInternal("b3Printf[%s,%d]:",__FILE__,__LINE__);b3OutputPrintfVarArgsInternal(__VA_ARGS__); } while(0) //#define b3Printf b3OutputPrintfVarArgsInternal //#define b3Printf(...) printf(__VA_ARGS__) //#define b3Printf(...) -#define b3Warning(...) {b3OutputWarningMessageVarArgsInternal("b3Warning[%s,%d]:\n",__FILE__,__LINE__);b3OutputWarningMessageVarArgsInternal(__VA_ARGS__); } -#define b3Error(...) {b3OutputErrorMessageVarArgsInternal("b3Error[%s,%d]:\n",__FILE__,__LINE__);b3OutputErrorMessageVarArgsInternal(__VA_ARGS__); } +#define b3Warning(...) do {b3OutputWarningMessageVarArgsInternal("b3Warning[%s,%d]:\n",__FILE__,__LINE__);b3OutputWarningMessageVarArgsInternal(__VA_ARGS__); }while(0) +#define b3Error(...) do {b3OutputErrorMessageVarArgsInternal("b3Error[%s,%d]:\n",__FILE__,__LINE__);b3OutputErrorMessageVarArgsInternal(__VA_ARGS__); } while(0) #endif//B3_LOGGING_H \ No newline at end of file