bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: unitypes: Fix trouble caused by installed older versions of unitypes.h
Date: Sun, 20 Jun 2021 03:18:50 +0200	[thread overview]
Message-ID: <10759128.r2Ti8XXdCi@omega> (raw)

When building code that using unistr.h, which depends on unitypes.h,
on a machine that has an older libunistring installed, I get these compilation
errors:

"../gnulib-lib/unistr.h", line 377.38: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 379.40: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 381.40: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 532.41: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 534.43: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 536.43: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 541.41: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 543.43: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 545.43: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 550.42: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 552.44: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 554.44: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 560.42: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 562.44: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 564.44: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 569.41: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 571.43: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 573.43: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 578.42: 1506-275 (S) Unexpected text dest encountered.
"../gnulib-lib/unistr.h", line 580.44: 1506-275 (S) Unexpected text dest encountered.

The cause is that uniname.h has been included from the install location,
which included "unitypes.h" also from the install location. So, the
unitypes.h file in the build directory was ignored.

It is hard to come up with a general fix of this; but this workaround
fixes the issue.


2021-06-19  Bruno Haible  <bruno@clisp.org>

	unitypes: Fix trouble caused by installed older versions of unitypes.h.
	* modules/unitypes (configure.ac): Define _UC_RESTRICT through config.h.

diff --git a/modules/unitypes b/modules/unitypes
index 8d3ccf0..46ed80d 100644
--- a/modules/unitypes
+++ b/modules/unitypes
@@ -11,6 +11,22 @@ stdint
 configure.ac:
 gl_LIBUNISTRING_LIBHEADER([0.9.11], [unitypes.h])
 
+AH_VERBATIM([unitypes_restrict], [
+/* This definition is a duplicate of the one in unitypes.h.
+   It is here so that we can cope with an older version of unitypes.h
+   that does not contain this definition and that is pre-installed among
+   the public header files.  */
+# if defined __restrict \
+     || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \
+     || __clang_major__ >= 3
+#  define _UC_RESTRICT __restrict
+# elif 199901L <= __STDC_VERSION__ || defined restrict
+#  define _UC_RESTRICT restrict
+# else
+#  define _UC_RESTRICT
+# endif
+])
+
 Makefile.am:
 BUILT_SOURCES += $(LIBUNISTRING_UNITYPES_H)
 



                 reply	other threads:[~2021-06-20  1:19 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=10759128.r2Ti8XXdCi@omega \
    --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).