Naming conflict between Givaro and Factory

81 views
Skip to first unread message

Clement Pernet

unread,
Dec 3, 2021, 5:54:08 AM12/3/21
to sage-devel
Hi,

Working on

    https://trac.sagemath.org/ticket/32959

I hit a compilation error due to

sage/local/include/factory/factory.h: #define IntegerDomain 1

which conflicts with

sage/local/include/givaro/givinteger.h: using IntegerDomain = ZRing<Integer>

See the compilation log ;

[sagelib-9.5.beta7] In file included from /home/soft/sage/local/include/singular/coeffs/coeffs.h:19,
[sagelib-9.5.beta7]                  from
/home/soft/sage/local/include/singular/polys/monomials/ring.h:12,
[sagelib-9.5.beta7]                  from /home/soft/sage/local/include/singular/kernel/polys.h:15,
[sagelib-9.5.beta7]                  from /home/soft/sage/local/include/singular/kernel/structs.h:25,
[sagelib-9.5.beta7]                  from
/home/soft/sage/local/include/singular/Singular/libsingular.h:7,
[sagelib-9.5.beta7]                  from
build/cythonized/sage/rings/polynomial/multi_polynomial_libsingular.cpp:724:
[sagelib-9.5.beta7] /home/soft/sage/local/include/givaro/givinteger.h: At global scope:
[sagelib-9.5.beta7] /home/soft/sage/local/include/factory/factory.h:92:23: error: expected
nested-name-specifier before numeric constant
[sagelib-9.5.beta7]    92 | #define IntegerDomain 1
[sagelib-9.5.beta7]       |                       ^
[sagelib-9.5.beta7] /home/soft/sage/local/include/givaro/givinteger.h:412:11: note: in expansion of
macro ‘IntegerDomain’
[sagelib-9.5.beta7]   412 |     using IntegerDomain = ZRing<Integer>;
[sagelib-9.5.beta7]       |           ^~~~~~~~~~~~~

I have no clue what is this Factory, and why it defines IntegerDomain to 1.

Any insight would be most welcome.

Cheers.

Clément


Maarten Derickx

unread,
Dec 3, 2021, 10:23:18 AM12/3/21
to sage-devel
Well factory.h is a file generated by singular using this template:
and that template uses: https://www.singular.uni-kl.de/dox/html/cf__defs_8h_source.html
Not really sure why they #define IntegerDomain 1 on line 25 there. But I guess that doesn't matter. It is just an occasion of having to different libraries accidentally using the same name for different things.

So this just means we should be careful with includes and other things so that these things don't clash.
Op vrijdag 3 december 2021 om 11:54:08 UTC+1 schreef Clement Pernet:

Clement Pernet

unread,
Dec 6, 2021, 9:42:09 AM12/6/21
to Maarten Derickx, sage-devel
Thanks, I also recently realized it was coming from Singular.


Le 03/12/2021 à 16:10, Maarten Derickx a écrit :

> Not really sure why they #define IntegerDomain 1 on line 25 there. But I guess that doesn't matter.> It is just an occasion of having to different libraries accidentally using the same name for
> different things.
Sure, that's why one should use namespaces as much as possible. Macros defined like this one are
very invasive as they even conflict with names protected in a namespace, like Givaro's. It could be
fixed by
- either prefixing the macro with something like __SINGULAR in ordre to emulate a namespace
- or #undef'ing it at the end of Singular's code.

>
> So this just means we should be careful with includes and other things so that these things don't clash.

Not sure that is can be solved by only re-ordering or carefully picking the includes.

Is anyone from singular around here who sees an alternative way around it?
I'll report the problem upstream.

Clément

> Op vrijdag 3 december 2021 om 11:54:08 UTC+1 schreef Clement Pernet:
>
> Hi,
>
> Working on
>
>     https://trac.sagemath.org/ticket/32959 <https://trac.sagemath.org/ticket/32959>
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> sage-devel+...@googlegroups.com <mailto:sage-devel+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/41bfbe41-5c62-428a-bd93-a5a2c0c5a0e3n%40googlegroups.com <https://groups.google.com/d/msgid/sage-devel/41bfbe41-5c62-428a-bd93-a5a2c0c5a0e3n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Dima Pasechnik

unread,
Dec 6, 2021, 11:21:21 AM12/6/21
to sage-devel, Maarten Derickx


On Mon, 6 Dec 2021, 14:42 Clement Pernet, <clement...@gmail.com> wrote:
Thanks, I also recently realized it was coming from Singular.


Le 03/12/2021 à 16:10, Maarten Derickx a écrit :

> Not really sure why they #define IntegerDomain 1 on line 25 there. But I guess that doesn't matter.> It is just an occasion of having to different libraries accidentally using the same name for
> different things.
Sure, that's why one should use namespaces as much as possible. Macros defined like this one are
very invasive as they even conflict with names protected in a namespace, like Givaro's. It could be
fixed by
- either prefixing the macro with something like __SINGULAR in ordre to emulate a namespace
- or #undef'ing it at the end of Singular's code.

>
> So this just means we should be careful with includes and other things so that these things don't clash.

Not sure that is can be solved by only re-ordering or carefully picking the includes.

Is anyone from singular around here who sees an alternative way around it?
I'll report the problem upstream.

it seems they had that macro for 26 years :-)

Surely they ought to replace all that with enums...

To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/72707f27-2041-4bce-e4d2-f103d3dac801%40gmail.com.

Clement Pernet

unread,
Dec 6, 2021, 11:50:21 AM12/6/21
to sage-...@googlegroups.com, Dima Pasechnik, Maarten Derickx
For the record, I reported the problem

https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2965&start=0

and a fix has quickly been commited.
I will include this fix as a patch to singular in the branch of

https://trac.sagemath.org/ticket/32959

where the conflict occured.

Clément
> > sage-devel+...@googlegroups.com <mailto:sage-devel%2Bunsu...@googlegroups.com>
> <mailto:sage-devel+...@googlegroups.com <mailto:sage-devel%2Bunsu...@googlegroups.com>>.
> <https://groups.google.com/d/msgid/sage-devel/41bfbe41-5c62-428a-bd93-a5a2c0c5a0e3n%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/sage-devel/41bfbe41-5c62-428a-bd93-a5a2c0c5a0e3n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> sage-devel+...@googlegroups.com <mailto:sage-devel%2Bunsu...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/72707f27-2041-4bce-e4d2-f103d3dac801%40gmail.com
> <https://groups.google.com/d/msgid/sage-devel/72707f27-2041-4bce-e4d2-f103d3dac801%40gmail.com>.
>
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> sage-devel+...@googlegroups.com <mailto:sage-devel+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/CAAWYfq05mNtNbWgF8McQOHLUraB%3D_6sooUwPRXGiWTLXg-xtZw%40mail.gmail.com
> <https://groups.google.com/d/msgid/sage-devel/CAAWYfq05mNtNbWgF8McQOHLUraB%3D_6sooUwPRXGiWTLXg-xtZw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Matthias Koeppe

unread,
Dec 6, 2021, 1:55:12 PM12/6/21
to sage-devel
Since https://trac.sagemath.org/ticket/29024 Sage uses suitable system installations of Singular, so it cannot be assumed that you can patch away this problem

Dima Pasechnik

unread,
Dec 6, 2021, 2:47:56 PM12/6/21
to sage-devel
On Mon, 6 Dec 2021, 18:55 Matthias Koeppe, <matthia...@gmail.com> wrote:
Since https://trac.sagemath.org/ticket/29024 Sage uses suitable system installations of Singular, so it cannot be assumed that you can patch away this problem

one can install a patched header into SAGE_LOCAL/include/ and use it instead of the system's one.

To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/3b2afe48-c8f2-48ce-97d1-78c92e9e3a0dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages