Bill Allombert on Sat, 27 Jun 2009 01:56:14 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Pari svn on MSVC


On Fri, Jun 26, 2009 at 10:59:28PM +0100, Jason Moxham wrote:
> in the file
> src/language/es.c
>
> in the function
>
> /* print e to S (more efficient than sprintf) */
> static void
> str_ulong(outString *S, ulong e)
> {
>  if (e == 0) str_putc(S, '0');
>  else
>  {
>    const int MAX = 21;
>    char buf[MAX], *p = buf + MAX;
>    *--p = 0;
>    if (e > 9) {
>      do
>        *--p = "0123456789"[e % 10];
>      while ((e /= 10) > 9);
>    }
>    *--p = "0123456789"[e];
>    str_puts(S, p);
>  }
> }
>
>
> char buf[MAX] is not recognized as a buffer of fixed lenght on MSVC v9.0  
> whereas clearly it is.

Does that cause a compiler failure ? Even gcc 2.95 handles that.

> I'm not sure what to suggest for this , perhaps a
>
> #define MAX 21
>
> or
>
> char buf[21] ;
> chat *p=buf+sizeof(buf)/sizeof(buf[0]);

The second seems better (because it is more localized).

Cheers,
Bill.