Skip to content

msys2 + mingw-w64 : warning with 'long' usage #280

@vtorri

Description

@vtorri

with latest git, i have (among others) these 2 warnings :

../src/check.h:1728:101: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
 1728 |   ck_assert_msg(_ck_x OP _ck_y, "Assertion '%s' failed: %s == %#lx, %s == %#lx", #X" "#OP" "#Y, #X, (unsigned long)_ck_x, #Y, (unsigned long)_ck_y); \
      |                                                                                                     ^

and

 1739 |   #X, (unsigned long)_ck_x); \
      |       ^

they are fixed with this patch :

index a1db8cd..45faec0 100644
--- a/src/check.h.in
+++ b/src/check.h.in
@@ -1725,7 +1725,7 @@ do { \
 #define _ck_assert_ptr(X, OP, Y) do { \
   const void* _ck_x = (X); \
   const void* _ck_y = (Y); \
-  ck_assert_msg(_ck_x OP _ck_y, "Assertion '%s' failed: %s == %#lx, %s == %#lx", #X" "#OP" "#Y, #X, (unsigned long)_ck_x, #Y, (unsigned long)_ck_y); \
+  ck_assert_msg(_ck_x OP _ck_y, "Assertion '%s' failed: %s == %#lx, %s == %#lx", #X" "#OP" "#Y, #X, (unsigned long)(uintptr_t)_ck_x, #Y, (unsigned long)(uintptr_t)_ck_y); \
 } while (0)

 /* Pointer against NULL comparison macros with improved output
@@ -1736,7 +1736,7 @@ do { \
   ck_assert_msg(_ck_x OP NULL, \
   "Assertion '%s' failed: %s == %#lx", \
   #X" "#OP" NULL", \
-  #X, (unsigned long)_ck_x); \
+  #X, (unsigned long)(uintptr_t)_ck_x); \
 } while (0)

 /**

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions