diff mbox series

[e2fsprogs] blkid: fix building e2fsprogs with internal libblkid

Message ID 20180302052135.25913-1-ebiggers3@gmail.com
State Accepted, archived
Headers show
Series [e2fsprogs] blkid: fix building e2fsprogs with internal libblkid | expand

Commit Message

Eric Biggers March 2, 2018, 5:21 a.m. UTC
From: Eric Biggers <ebiggers@google.com>

Building e2fsprogs with the internal libblkid fails for me with the
following compiler error:

	In file included from blkidP.h:27:0,
			 from dev.c:17:
	dev.c: In function ‘blkid_free_dev’:
	../../lib/blkid/list.h:149:42: error: ‘intptr_t’ undeclared (first use in this function); did you mean ‘__intptr_t’?
	  ((type *)((char *)(ptr)-(unsigned long)(intptr_t)(&((type *)0)->member)))

The problem is that lib/blkid/list.h is now using 'intptr_t', but
stdint.h is not guaranteed to have been included yet.  Include it.

Fixes: 0a3d8041892c ("AOSP: build mke2fs for windows using android mingw library")
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 lib/blkid/list.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Theodore Ts'o March 2, 2018, 9:53 p.m. UTC | #1
On Thu, Mar 01, 2018 at 09:21:35PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> Building e2fsprogs with the internal libblkid fails for me with the
> following compiler error:
> 
> 	In file included from blkidP.h:27:0,
> 			 from dev.c:17:
> 	dev.c: In function ‘blkid_free_dev’:
> 	../../lib/blkid/list.h:149:42: error: ‘intptr_t’ undeclared (first use in this function); did you mean ‘__intptr_t’?
> 	  ((type *)((char *)(ptr)-(unsigned long)(intptr_t)(&((type *)0)->member)))
> 
> The problem is that lib/blkid/list.h is now using 'intptr_t', but
> stdint.h is not guaranteed to have been included yet.  Include it.
> 
> Fixes: 0a3d8041892c ("AOSP: build mke2fs for windows using android mingw library")
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Thanks for pointing this out!  I've fixed slightly modified your patch
to try using inttypes.h preferentially and to use HAVE_xxx_H #ifdefs,
e.g:

#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#else
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#endif

					- Ted
diff mbox series

Patch

diff --git a/lib/blkid/list.h b/lib/blkid/list.h
index 7e0ccd77..bd29f284 100644
--- a/lib/blkid/list.h
+++ b/lib/blkid/list.h
@@ -5,6 +5,8 @@ 
 extern "C" {
 #endif
 
+#include <stdint.h>
+
 #ifdef __GNUC__
 #define _INLINE_ static __inline__
 #else                         /* For Watcom C */