Work around gcc compiler bug

* It complains that there is switch fallthrough after an unconditional return,
  when it's inside a do{}while(0). Simplifying the while condition seems to
  address it.
This commit is contained in:
baldurk
2022-04-26 17:37:31 +01:00
parent 8aa0390948
commit 16f3764cda
+16 -16
View File
@@ -55,35 +55,35 @@ DECLARE_REFLECTION_STRUCT(RDResult);
// helper macros since we often want to print the error message that gets returned.
// one helper returns immediately, the other sets a result and prints - to allow cleanup
#define RETURN_ERROR_RESULT_INTERNAL(code, msg, ...) \
do \
{ \
RDResult res##__LINE__(code, StringFormat::Fmt(STRING_LITERAL(msg), __VA_ARGS__)); \
RDCERR("%s", res##__LINE__.message.c_str()); \
return res##__LINE__; \
} while((void)0, 0)
#define RETURN_ERROR_RESULT_INTERNAL(code, msg, ...) \
do \
{ \
RDResult CONCAT(res, __LINE__)(code, StringFormat::Fmt(STRING_LITERAL(msg), __VA_ARGS__)); \
RDCERR("%s", CONCAT(res, __LINE__).message.c_str()); \
return CONCAT(res, __LINE__); \
} while(0)
#define SET_ERROR_RESULT_INTERNAL(res, code, msg, ...) \
do \
{ \
res = RDResult(code, StringFormat::Fmt(STRING_LITERAL(msg), __VA_ARGS__)); \
RDCERR("%s", res.message.c_str()); \
} while((void)0, 0)
} while(0)
#define RETURN_WARNING_RESULT_INTERNAL(code, msg, ...) \
do \
{ \
RDResult res##__LINE__(code, StringFormat::Fmt(STRING_LITERAL(msg), __VA_ARGS__)); \
RDCWARN("%s", res##__LINE__.message.c_str()); \
return res##__LINE__; \
} while((void)0, 0)
#define RETURN_WARNING_RESULT_INTERNAL(code, msg, ...) \
do \
{ \
RDResult CONCAT(res, __LINE__)(code, StringFormat::Fmt(STRING_LITERAL(msg), __VA_ARGS__)); \
RDCWARN("%s", CONCAT(res, __LINE__).message.c_str()); \
return CONCAT(res, __LINE__); \
} while(0)
#define SET_WARNING_RESULT_INTERNAL(res, code, msg, ...) \
do \
{ \
res = RDResult(code, StringFormat::Fmt(STRING_LITERAL(msg), __VA_ARGS__)); \
RDCWARN("%s", res.message.c_str()); \
} while((void)0, 0)
} while(0)
// VS automatically elides any trailing comma if there are no arguments above. GCC/Clang are
// stricter and may fail, so we add an extra 0 since it won't get processed by the format anyway