summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKunYi Chen <[email protected]>2024-10-25 12:14:39 +0800
committerMeco Man <[email protected]>2024-10-25 22:22:09 -0400
commit6b7f1177deeae01a7092c22a89cd41e7b318f01c (patch)
tree756bf0ce0bbfb8d41a5f9e03ee38742a59835518
parentee1490736c7d0f110c3a6fcde428c65dda1b29ac (diff)
fix: suppress unused warnings when DEBUG disabled
When RT_USING_DEBUG is disabled, variables used only in RT_ASSERT statements become unused, triggering -Wunused-but-set-variable compiler warnings. These variables are essential for runtime assertions in debug builds but appear unused in release builds. Example: - Variables used in RT_ASSERT(var != RT_NULL) checks - Affects multiple drivers and components using RT_ASSERT This is a general cleanup to improve code compilation without affecting functionality.
-rw-r--r--include/rtdef.h2
-rw-r--r--include/rtthread.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/include/rtdef.h b/include/rtdef.h
index 34bb283ae7..0d5c421759 100644
--- a/include/rtdef.h
+++ b/include/rtdef.h
@@ -117,7 +117,7 @@ extern "C" {
/* Common Utilities */
-#define RT_UNUSED(x) ((void)x)
+#define RT_UNUSED(x) ((void)(x))
/* compile time assertion */
#define RT_STATIC_ASSERT(name, expn) typedef char _static_assert_##name[(expn)?1:-1]
diff --git a/include/rtthread.h b/include/rtthread.h
index 311516bd8b..e6740d46da 100644
--- a/include/rtthread.h
+++ b/include/rtthread.h
@@ -804,7 +804,7 @@ if (!(EX)) \
rt_assert_handler(#EX, __FUNCTION__, __LINE__); \
}
#else
-#define RT_ASSERT(EX)
+#define RT_ASSERT(EX) {RT_UNUSED(EX);}
#endif /* RT_DEBUGING_ASSERT */
#ifdef RT_DEBUGING_CONTEXT