bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* unictype/category-none tests: Fix a link error on MSVC
@ 2022-09-04 22:32 Bruno Haible
  2022-09-06 11:11 ` Simon Josefsson via Gnulib discussion list
  0 siblings, 1 reply; 3+ messages in thread
From: Bruno Haible @ 2022-09-04 22:32 UTC (permalink / raw)
  To: bug-gnulib

On MSVC, with libunistring installed as a shared library, I get this link
error:

/home/bruno/msvc/compile cl -nologo  -MD  -L/usr/local/msvc64/lib -o test-categ_none.exe unictype/test-categ_none.obj libtests.a ../gllib/libgnu.a libtests.a ../gllib/libgnu.a libtests.a  -lunistring 
test-categ_none.obj : error LNK2019: unresolved external symbol _UC_CATEGORY_NONE referenced in function main
test-categ_none.exe : fatal error LNK1120: 1 unresolved externals
make[4]: *** [Makefile:16335: test-categ_none.exe] Error 2

The reason is that _UC_CATEGORY_NONE is not a public API of the shared library
and therefore not exported. The simplest fix is to disable the test.


2022-09-04  Bruno Haible  <bruno@clisp.org>

	unictype/category-none tests: Fix a link error on MSVC.
	* tests/unictype/test-categ_none.c (main): Disable the test on MSVC.

diff --git a/tests/unictype/test-categ_none.c b/tests/unictype/test-categ_none.c
index 4615fb162b..913011a5e4 100644
--- a/tests/unictype/test-categ_none.c
+++ b/tests/unictype/test-categ_none.c
@@ -25,11 +25,18 @@
 int
 main ()
 {
+  /* This test cannot be compiled on platforms on which _UC_CATEGORY_NONE
+     is not exported from the libunistring shared library.  For now,
+     MSVC is the only platform where this is a problem.  */
+#if !defined _MSC_VER
+
   uc_general_category_t ct = _UC_CATEGORY_NONE;
   unsigned int c;
 
   for (c = 0; c < 0x110000; c++)
     ASSERT (!uc_is_general_category (c, ct));
 
+#endif
+
   return 0;
 }





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: unictype/category-none tests: Fix a link error on MSVC
  2022-09-04 22:32 unictype/category-none tests: Fix a link error on MSVC Bruno Haible
@ 2022-09-06 11:11 ` Simon Josefsson via Gnulib discussion list
  2024-02-24  0:41   ` Bruno Haible
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Josefsson via Gnulib discussion list @ 2022-09-06 11:11 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 1788 bytes --]

Bruno Haible <bruno@clisp.org> writes:

> On MSVC, with libunistring installed as a shared library, I get this link
> error:
>
> /home/bruno/msvc/compile cl -nologo  -MD  -L/usr/local/msvc64/lib -o test-categ_none.exe unictype/test-categ_none.obj libtests.a ../gllib/libgnu.a libtests.a ../gllib/libgnu.a libtests.a  -lunistring 
> test-categ_none.obj : error LNK2019: unresolved external symbol _UC_CATEGORY_NONE referenced in function main
> test-categ_none.exe : fatal error LNK1120: 1 unresolved externals
> make[4]: *** [Makefile:16335: test-categ_none.exe] Error 2
>
> The reason is that _UC_CATEGORY_NONE is not a public API of the shared library
> and therefore not exported. The simplest fix is to disable the test.

Thanks -- although isn't that also a bug in libunistring that the symbol
is visible for non-MSVC?  Shouldn't be hidden?

/Simon

>
> 2022-09-04  Bruno Haible  <bruno@clisp.org>
>
> 	unictype/category-none tests: Fix a link error on MSVC.
> 	* tests/unictype/test-categ_none.c (main): Disable the test on MSVC.
>
> diff --git a/tests/unictype/test-categ_none.c b/tests/unictype/test-categ_none.c
> index 4615fb162b..913011a5e4 100644
> --- a/tests/unictype/test-categ_none.c
> +++ b/tests/unictype/test-categ_none.c
> @@ -25,11 +25,18 @@
>  int
>  main ()
>  {
> +  /* This test cannot be compiled on platforms on which _UC_CATEGORY_NONE
> +     is not exported from the libunistring shared library.  For now,
> +     MSVC is the only platform where this is a problem.  */
> +#if !defined _MSC_VER
> +
>    uc_general_category_t ct = _UC_CATEGORY_NONE;
>    unsigned int c;
>  
>    for (c = 0; c < 0x110000; c++)
>      ASSERT (!uc_is_general_category (c, ct));
>  
> +#endif
> +
>    return 0;
>  }
>
>
>
>
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 255 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: unictype/category-none tests: Fix a link error on MSVC
  2022-09-06 11:11 ` Simon Josefsson via Gnulib discussion list
@ 2024-02-24  0:41   ` Bruno Haible
  0 siblings, 0 replies; 3+ messages in thread
From: Bruno Haible @ 2024-02-24  0:41 UTC (permalink / raw)
  To: Simon Josefsson; +Cc: bug-gnulib

Simon Josefsson wrote
in <https://lists.gnu.org/archive/html/bug-gnulib/2022-09/msg00039.html>:
> > The reason is that _UC_CATEGORY_NONE is not a public API of the shared library
> > and therefore not exported. The simplest fix is to disable the test.
> 
> Thanks -- although isn't that also a bug in libunistring that the symbol
> is visible for non-MSVC?  Shouldn't be hidden?

It could be hidden. But then I would have to remove the unit test
tests/unictype/test-categ_none.c. I prefer to keep this unit test
and run it at least on ELF platforms, for code coverage reasons.

Bruno





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-24  0:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-04 22:32 unictype/category-none tests: Fix a link error on MSVC Bruno Haible
2022-09-06 11:11 ` Simon Josefsson via Gnulib discussion list
2024-02-24  0:41   ` Bruno Haible

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).