[Sage] #11246: flint-1.5.0.p5 defines ulong on a system with ulong a type

19 views
Skip to first unread message

Dima Pasechnik

unread,
Apr 24, 2011, 7:22:29 AM4/24/11
to sage-devel, sage-w...@googlegroups.com
While trying to build Sage on Windows 7, I ran into the case of a
package defining ulong (i.e. #define ulong unsigned long),
whereas in a system header it is defined as a type.
(details on the ticket).

While it's trivial to make a platform-dependent fix, I wonder whether
this should be addressed in some other, more proper way
(indeed, one sees that on various linuxes this happens once in a
while, too)...

Dima

Dr. David Kirkby

unread,
Apr 24, 2011, 3:20:06 PM4/24/11
to sage-w...@googlegroups.com

#ifndef ulong
#define ulong unsigned long
#endif

would not be platform specific (so fairly easy to maintain).

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

Dave

Bill Hart

unread,
Apr 24, 2011, 3:41:27 PM4/24/11
to sage-w...@googlegroups.com
On 24 April 2011 20:20, Dr. David Kirkby <david....@onetel.net> wrote:
> On 04/24/11 12:22 PM, Dima Pasechnik wrote:
>>
>> While trying to build Sage on Windows 7, I ran into the case of a
>> package defining ulong (i.e. #define ulong unsigned long),
>> whereas in a system header it is defined as a type.
>> (details on the ticket).
>>
>> While it's trivial to make a platform-dependent fix, I wonder whether
>> this should be addressed in some other, more proper way
>> (indeed, one sees that on various linuxes this happens once in a
>> while, too)...
>>
>> Dima
>>
>
> #ifndef ulong
> #define ulong unsigned long
> #endif
>
> would not be platform specific (so fairly easy to maintain).
>

What I've been doing is #undef ulong before including those header
files, then #define ulong unsigned long after they're included. This
seems to work.

Bill.

David Kirkby

unread,
Apr 24, 2011, 3:49:07 PM4/24/11
to sage-w...@googlegroups.com

Is there any reason not to use "unsigned long", rather than #define
ulong to it?

Dave

Bill Hart

unread,
Apr 24, 2011, 3:49:47 PM4/24/11
to sage-w...@googlegroups.com

No.

David Kirkby

unread,
Apr 24, 2011, 4:07:59 PM4/24/11
to sage-w...@googlegroups.com

In which case I'd suggest that removing the use of "ulong" and just
using "unsigned long" would be the best solution.

Dave

Bill Hart

unread,
Apr 24, 2011, 5:48:58 PM4/24/11
to sage-w...@googlegroups.com

Best of luck.

Dima Pasechnik

unread,
Apr 24, 2011, 10:02:12 PM4/24/11
to sage-windows


On Apr 25, 3:41 am, Bill Hart <goodwillh...@googlemail.com> wrote:
it is not done consistently: it is done in profiler.h, but not in
flint.h
(and the latter seems to be the culprit here, as it's just the stdio.h
inclusion that
causes the error).

I'll make a patch.

Dima

>
> Bill.

Dr. David Kirkby

unread,
Apr 25, 2011, 4:55:31 AM4/25/11
to sage-w...@googlegroups.com

Well, the upstream developer should seriously consider fixing this.

Dima Pasechnik

unread,
Apr 25, 2011, 10:24:34 AM4/25/11
to Bill Hart, sage-w...@googlegroups.com
Hi Bill,

On Apr 25, 3:41 am, Bill Hart <goodwillh...@googlemail.com> wrote:

> On 24 April 2011 20:20, Dr. David Kirkby <david.kir...@onetel.net> wrote:
> > On 04/24/11 12:22 PM, Dima Pasechnik wrote:
>
> >> While trying to build Sage on Windows 7, I ran into the case of a
> >> package defining ulong (i.e. #define ulong unsigned long),
> >> whereas in a system header it is defined as a type.
> >> (details on the ticket).
>
> >> While it's trivial to make a platform-dependent fix, I wonder whether
> >> this should be addressed in some other, more proper way
> >> (indeed, one sees that on various linuxes this happens once in a
> >> while, too)...
>
> >> Dima
>
> > #ifndef ulong
> > #define ulong unsigned long
> > #endif
>
> > would not be platform specific (so fairly easy to maintain).

This does not work, as the header inclusion order in ZmodF_mul.c
does #include ZmodF_poly.h (which includes stdio.h, which in turn
includes sys/types.h containing the typedef for ulong)
after ZmodF.h, which includes flint.h containing #define ulong

Thus the typedef is nuked, and there is no way around it with the
given header
order.

The 1st bug is in ZmodF_mul.c, which does not need to include ZmodF.h
at all,
as it is included in ZmodF_poly.h

The 2nd bug like this is in mpn_extras.h, where the inclusion of
flint.h is not needed
---and this nukes ZmodF_mul-tuning.c

The 3rd bug like this is in ZmodF_poly.c, which needs to include
neither flint.h nor memory-manager.h

After removing these includes, the spkg compiles on Cygwin.

Dmitrii

Dima Pasechnik

unread,
Apr 25, 2011, 12:20:47 PM4/25/11
to sage-devel, sage-w...@googlegroups.com
it's fixed in http://trac.sagemath.org/sage_trac/ticket/11246
which needs review.

On Apr 25, 10:32 pm, David Kirkby <david.kir...@onetel.net> wrote:


> On 25 April 2011 15:25, Dima Pasechnik <dimp...@gmail.com> wrote:
>
> >> > #ifndef ulong
> >> > #define ulong unsigned long
> >> > #endif
>
> >> > would not be platform specific (so fairly easy to maintain).
>
> > This does not work, as the header inclusion order in ZmodF_mul.c
> > does #include ZmodF_poly.h (which includes stdio.h, which in turn
> > includes sys/types.h containing the typedef for ulong)
> > after ZmodF.h, which includes flint.h containing #define ulong
>
> > Thus the typedef is nuked, and there is no way around it with the
> > given header
>

> I doubt Bill will change it, but personally I feel there's no need to
> use ulong at all, and he should use "unsigned long" in his code. He
> has invented something that saves 6 byes every time it is used, but
> causes unnecessary complications.
>
> I think the KISS principle should apply here.
>
> Dave

Reply all
Reply to author
Forward
0 new messages