Bruno Haible
2018-05-13 23:02:23 UTC
This error
In file included from ./signal.h:67:0,
from /ANDROID_SDK/ndk-bundle/sysroot/usr/include/sys/select.h:36,
from ./sys/select.h:100,
from /ANDROID_SDK/ndk-bundle/sysroot/usr/include/sys/time.h:37,
from ./sys/time.h:39,
from /ANDROID_SDK/ndk-bundle/sysroot/usr/include/time.h:33,
from ./time.h:41,
from /ANDROID_SDK/ndk-bundle/sysroot/usr/include/pthread.h:37,
from ./pthread.h:30,
from glthread/threadlib.c:27:
/ANDROID_SDK/ndk-bundle/sysroot/usr/include/pthread.h:42:3: error: expected identifier before numeric constant
PTHREAD_MUTEX_NORMAL = 0,
^
is a consequence of recursive inclusion of the same file. The fix is to
use the same idiom as in locale.in.h, signal.in.h, stdio.in.h, string.in.h,
sys_socket.in.h, wchar.in.h.
2018-05-13 Bruno Haible <***@clisp.org>
pthread: Fix compilation error on Android.
* lib/pthread.in.h: Use _GL_ALREADY_INCLUDING_PTHREAD_H to shortcut
recursive inclusion of this file.
diff --git a/lib/pthread.in.h b/lib/pthread.in.h
index 73a98e2..69d643a 100644
--- a/lib/pthread.in.h
+++ b/lib/pthread.in.h
@@ -17,16 +17,35 @@
/* Written by Paul Eggert and Glen Lenker. */
-#ifndef ***@GUARD_PREFIX@_PTHREAD_H_
-
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
-/* The include_next requires a split double-inclusion guard. */
+#if defined _GL_ALREADY_INCLUDING_PTHREAD_H
+/* Special invocation convention:
+ On Android, we have a sequence of nested includes
+ <pthread.h> -> <time.h> -> <sys/time.h> -> <sys/select.h> ->
+ <signal.h> -> <pthread.h>.
+ In this situation, PTHREAD_COND_INITIALIZER is not yet defined,
+ therefore we should not attempt to define PTHREAD_MUTEX_NORMAL etc. */
+
+#@INCLUDE_NEXT@ @NEXT_PTHREAD_H@
+
+#else
+/* Normal invocation convention. */
+
+#ifndef ***@GUARD_PREFIX@_PTHREAD_H_
+
#if @HAVE_PTHREAD_H@
+
+# define _GL_ALREADY_INCLUDING_PTHREAD_H
+
+/* The include_next requires a split double-inclusion guard. */
# @INCLUDE_NEXT@ @NEXT_PTHREAD_H@
+
+# undef _GL_ALREADY_INCLUDING_PTHREAD_H
+
#endif
#ifndef ***@GUARD_PREFIX@_PTHREAD_H_
@@ -293,3 +312,4 @@ _GL_INLINE_HEADER_END
#endif /* ***@GUARD_PREFIX@_PTHREAD_H_ */
#endif /* ***@GUARD_PREFIX@_PTHREAD_H_ */
+#endif
In file included from ./signal.h:67:0,
from /ANDROID_SDK/ndk-bundle/sysroot/usr/include/sys/select.h:36,
from ./sys/select.h:100,
from /ANDROID_SDK/ndk-bundle/sysroot/usr/include/sys/time.h:37,
from ./sys/time.h:39,
from /ANDROID_SDK/ndk-bundle/sysroot/usr/include/time.h:33,
from ./time.h:41,
from /ANDROID_SDK/ndk-bundle/sysroot/usr/include/pthread.h:37,
from ./pthread.h:30,
from glthread/threadlib.c:27:
/ANDROID_SDK/ndk-bundle/sysroot/usr/include/pthread.h:42:3: error: expected identifier before numeric constant
PTHREAD_MUTEX_NORMAL = 0,
^
is a consequence of recursive inclusion of the same file. The fix is to
use the same idiom as in locale.in.h, signal.in.h, stdio.in.h, string.in.h,
sys_socket.in.h, wchar.in.h.
2018-05-13 Bruno Haible <***@clisp.org>
pthread: Fix compilation error on Android.
* lib/pthread.in.h: Use _GL_ALREADY_INCLUDING_PTHREAD_H to shortcut
recursive inclusion of this file.
diff --git a/lib/pthread.in.h b/lib/pthread.in.h
index 73a98e2..69d643a 100644
--- a/lib/pthread.in.h
+++ b/lib/pthread.in.h
@@ -17,16 +17,35 @@
/* Written by Paul Eggert and Glen Lenker. */
-#ifndef ***@GUARD_PREFIX@_PTHREAD_H_
-
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
-/* The include_next requires a split double-inclusion guard. */
+#if defined _GL_ALREADY_INCLUDING_PTHREAD_H
+/* Special invocation convention:
+ On Android, we have a sequence of nested includes
+ <pthread.h> -> <time.h> -> <sys/time.h> -> <sys/select.h> ->
+ <signal.h> -> <pthread.h>.
+ In this situation, PTHREAD_COND_INITIALIZER is not yet defined,
+ therefore we should not attempt to define PTHREAD_MUTEX_NORMAL etc. */
+
+#@INCLUDE_NEXT@ @NEXT_PTHREAD_H@
+
+#else
+/* Normal invocation convention. */
+
+#ifndef ***@GUARD_PREFIX@_PTHREAD_H_
+
#if @HAVE_PTHREAD_H@
+
+# define _GL_ALREADY_INCLUDING_PTHREAD_H
+
+/* The include_next requires a split double-inclusion guard. */
# @INCLUDE_NEXT@ @NEXT_PTHREAD_H@
+
+# undef _GL_ALREADY_INCLUDING_PTHREAD_H
+
#endif
#ifndef ***@GUARD_PREFIX@_PTHREAD_H_
@@ -293,3 +312,4 @@ _GL_INLINE_HEADER_END
#endif /* ***@GUARD_PREFIX@_PTHREAD_H_ */
#endif /* ***@GUARD_PREFIX@_PTHREAD_H_ */
+#endif