Hi Collin,

> I had assumed GNULIB_NAMESPACE was supposed to be defined in C++ tests.
> Is that incorrect? I don't know C++ namespaces much.

The GNULIB_NAMESPACE is an optional setting, see
https://www.gnu.org/software/gnulib/manual/html_node/A-C_002b_002b-namespace-for-gnulib.html

Since it is optional, some unit tests turn it on while some other unit tests
don't.

Generally, working in C++ without GNULIB_NAMESPACE is more tricky,
because the '#define foo rpl_foo' replacements cause trouble each time
'foo' occurs in another context.

> Here is some expirementation I did. Using the following testdir:
> 
>     $ gnulib-tool --create-testdir --with-all-tests --dir testdir sys_un 
> memchr
> 
> Using clang and clang++ on master:
> 
>     # clang version 18.1.6 (Fedora 18.1.6-3.fc40)
>     $ ./configure CC='clang' CXX='clang++'
>     $ make
>     [...]
>     In file included from test-sys_un-c++.cc:24:
>     In file included from /usr/include/sys/un.h:38:
>     ../gllib/string.h:809:20: error: declaration of 'memchr' has a different 
> language linkage
>       809 | _GL_CXXALIASWARN1 (memchr, void *,
>           |                    ^
>     /usr/include/string.h:94:1: note: previous definition is here
>        94 | memchr (void *__s, int __c, size_t __n) __THROW
>           | ^
>     In file included from test-sys_un-c++.cc:24:
>     In file included from /usr/include/sys/un.h:38:
>     ../gllib/string.h:812:20: error: declaration of 'memchr' has a different 
> language linkage
>       812 | _GL_CXXALIASWARN1 (memchr, void const *,
>           |                    ^
>     /usr/include/string.h:100:1: note: previous definition is here
>       100 | memchr (const void *__s, int __c, size_t __n) __THROW
>           | ^
>     2 errors generated.
>     make[4]: *** [Makefile:1958: test-sys_un-c++.o] Error 1
>     $ echo $?
>     2
> 
> After removing the GNULIB_NAMESPACE definition in
> gltests/test-sys_un-c++.cc:
> 
>     # clang version 18.1.6 (Fedora 18.1.6-3.fc40)
>     $ ./configure CC='clang' CXX='clang++'
>     $ make
>     [...]
>     $ echo $?
>     0

Ah, interesting...

Bruno




Reply via email to