bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: math: Fix compilation errors in C++ mode on Android
Date: Tue, 10 Jan 2023 10:03:46 +0100	[thread overview]
Message-ID: <13365970.lhuNh5TYOU@nimes> (raw)

In a testdir on Android, I see many compilation errors here:

clang++ -ferror-limit=0 -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -I. -I../../gltests -I..  -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. -I../../gltests/.. -I../gllib -I../../gltests/../gllib -I/data/data/com.termux/files/home/local/include -Wall  -Wno-error -g -O2 -c -o test-math-c++2.o ../../gltests/test-math-c++2.cc
In file included from ../../gltests/test-math-c++2.cc:20:
In file included from /data/data/com.termux/files/usr/include/c++/v1/cmath:304:
In file included from /data/data/com.termux/files/usr/include/c++/v1/math.h:301:
In file included from ../gllib/stdlib.h:36:
In file included from /data/data/com.termux/files/usr/include/c++/v1/stdlib.h:20:
In file included from /data/data/com.termux/files/usr/include/stdlib.h:34:
In file included from ../gllib/malloc.h:42:
In file included from /data/data/com.termux/files/usr/include/malloc.h:30:
In file included from ../gllib/stdio.h:71:
In file included from ../gllib/sys/stat.h:44:
In file included from ../gllib/time.h:47:
In file included from /data/data/com.termux/files/usr/include/time.h:33:
In file included from ../gllib/sys/time.h:39:
In file included from /data/data/com.termux/files/usr/include/sys/time.h:37:
In file included from ../gllib/sys/select.h:102:
In file included from /data/data/com.termux/files/usr/include/sys/select.h:40:
In file included from ../gllib/signal.h:75:
In file included from ../gllib/pthread.h:56:
In file included from ../gllib/stdlib.h:28:
In file included from /data/data/com.termux/files/usr/include/c++/v1/stdlib.h:100:
../gllib/math.h:773:19: error: no member named 'acosf' in the global namespace
_GL_CXXALIAS_SYS (acosf, float, (float x));
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
...

The problem is that
  - /usr/include/c++/v1/math.h indirectly includes gllib/math.h before
    /usr/include/math.h has been included,
  - The line '#include_next <math.h>' in gllib/math.h includes
    /usr/include/c++/v1/math.h, which expands to empty since it is being
    included.

This patch fixes it.


2023-01-10  Bruno Haible  <bruno@clisp.org>

	math: Fix compilation errors in C++ mode on Android.
	* lib/math.in.h: Declare nothing if this file gets included from
	/usr/include/c++/v1/math.h too early.

diff --git a/lib/math.in.h b/lib/math.in.h
index f3d58afc0d..a1cb22936b 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -15,6 +15,11 @@
    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
+/* On Android, in C++ mode, when /usr/include/c++/v1/math.h is being included
+   and /usr/include/math.h has not yet been included, skip this file, since it
+   would lead to many syntax errors.  */
+#if !(defined __ANDROID__ && defined _LIBCPP_MATH_H && !defined INFINITY)
+
 #ifndef _@GUARD_PREFIX@_MATH_H
 
 #if __GNUC__ >= 3
@@ -2725,3 +2730,4 @@ _GL_INLINE_HEADER_END
 #endif /* _@GUARD_PREFIX@_MATH_H */
 #endif /* _GL_INCLUDING_MATH_H */
 #endif /* _@GUARD_PREFIX@_MATH_H */
+#endif





                 reply	other threads:[~2023-01-10  9:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13365970.lhuNh5TYOU@nimes \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).