A test sequence such as:
const struct my_vtable expected_element;
struct my_vtable* test_element;
ck_assert_ptr_eq(test_element, &expected_element);
Compiled using gcc 4.7.2 with -Wall gives the following warning.
myfile.c:70:2: warning: initialization discards ‘const’ qualifier from pointer target type [enabled by default]
Adding a const qualifier to the variables in the _ck_assert_ptr macro,
as done for _ck_assert_str makes the problem go away.
Issue #91, patch submitted by user lordlod24.
git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@861
64e312b2-a51f-0410-8e61-
82d0ca0eb02a
Martin Willers (rename check's internal list API to start with check_)
bross (patches for msys/mingw32 support)
Pino Toscano (GNU/Hurd support for subsecond timeouts)
+ lod (compiler warning)
Anybody who has contributed code to Check or Check's build system is
considered an author. Send patches to this file to
In development:
-
+* fix ck_assert_ptr_* causing const compilation warnings. Patch from
+ bug #91.
Wed, Nov 4, 2013: Released Check 0.9.11
based on r856 (2013-11-04 02:09:21 +0000)
/* Pointer comparsion macros with improved output compared to ck_assert(). */
/* OP may only be == or != */
#define _ck_assert_ptr(X, OP, Y) do { \
- void* _ck_x = (X); \
- void* _ck_y = (Y); \
+ const void* _ck_x = (X); \
+ const void* _ck_y = (Y); \
ck_assert_msg(_ck_x OP _ck_y, "Assertion '"#X#OP#Y"' failed: "#X"==%#x, "#Y"==%#x", _ck_x, _ck_y); \
} while (0)
#define ck_assert_ptr_eq(X, Y) _ck_assert_ptr(X, ==, Y)