diff --git a/nestegg/halloc/src/macros.h b/nestegg/halloc/src/macros.h
index c36b516eed38c5728761b6c82d2829bcccc3324f..1f84bc2779363aacb31c010c4ea10f82f3060f2a 100644
--- a/nestegg/halloc/src/macros.h
+++ b/nestegg/halloc/src/macros.h
@@ -20,7 +20,7 @@
 /*
  	restore pointer to the structure by a pointer to its field
  */
-#define structof(p,t,f) ((t*)(- offsetof(t,f) + (char*)(p)))
+#define structof(p,t,f) ((t*)(- (ptrdiff_t) offsetof(t,f) + (char*)(p)))
 
 /*
  *	redefine for the target compiler