pw_assert: Fix missing NULL symbol
This adds the necessary stdint.h include to get the NULL symbol, and
also adds a test to ensure PW_CHECK_NOTNULL works in both C and C++.
Change-Id: I7524f520117b2df99efdf1120ec610fe7ab67d9a
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/11760
Reviewed-by: Kevin Zeng <zengk@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Keir Mierle <keir@google.com>
diff --git a/pw_assert/assert_backend_compile_test_c.c b/pw_assert/assert_backend_compile_test_c.c
index cecc756..6743554 100644
--- a/pw_assert/assert_backend_compile_test_c.c
+++ b/pw_assert/assert_backend_compile_test_c.c
@@ -24,6 +24,14 @@
#define PW_ASSERT_USE_SHORT_NAMES 1
#include "pw_assert/assert.h"
+
+static void EnsureNullIsIncluded() {
+ // This is a compile check to ensure NULL is defined. It comes before the
+ // status.h include to ensure we don't accidentally get NULL from status.h.
+ PW_CHECK_NOTNULL(0xa);
+ PW_CHECK_NOTNULL(0x0);
+}
+
#include "pw_status/status.h"
#ifdef __cplusplus
@@ -115,6 +123,9 @@
PW_CHECK_PTR_GE(x_ptr, y_ptr);
PW_CHECK_PTR_GE(x_ptr, y_ptr, "PTR: " FAIL_IF_HIDDEN);
PW_CHECK_PTR_GE(x_ptr, y_ptr, "PTR: " FAIL_IF_HIDDEN_ARGS, z);
+
+ PW_CHECK_NOTNULL(0xa);
+ PW_CHECK_NOTNULL(0x0);
}
{ // TEST(Check, FloatComparison)
@@ -193,4 +204,6 @@
PW_DCHECK_OK(PW_STATUS_OK, "msg");
PW_DCHECK_OK(PW_STATUS_OK, "msg: %d", 5);
}
+
+ EnsureNullIsIncluded();
}