[Snowball-discuss] Re: Compiling with VC++ 6?

From: J Smith (jsmith@tutorbuddy.com)
Date: Thu Apr 18 2002 - 18:52:23 BST


Naturally, the moment I hit send I get an idea and it turns out that it works.

Lines like this one:

static symbol s_0_0[0] = { };

When modified thusly...

static symbol s_0_0[1] = { '\0' };

... seem to work fine in both gcc and VC++. Since I'm not too familiar with
the Snowball source itself, I haven't looked into what would be involved in
generating these changes to the C source the engine outputs. From what I can
tell at a quick glance, since the first member of the among struct (s_size)
determines the number of characters being used in the symbol array, having a
size of 1 shouldn't matter, as it will be ignored since the declarations of
the among structs usually look something like this:

static struct among a_0[11] =
{
/* 0 */ { 0, s_0_0, -1, 6, 0},
etc.
};

This should make the output created by Snowball more ANSI/ISO compliant. (At
least it compiles on VC++... I tested the changes on VC++ 6 and gcc 2.96 on
linux and they both agree that this is "more" ANSI. (-pedantic doesn't give
warnings any more, no errors in VC++.)

Cheers,

J

On April 18, 2002 01:15 pm, I wrote:
> A month or two ago, I released a PHP extension that provided access to the
> stemmers created by Snowball. The extension worked fine for UNIX-like
> systems using gcc, but recently I've started porting the extension to
> Windows platforms and have been stuck. (Since PHP is supposed to provide a
> pretty decently portable language like Perl, I figured I had better make
> the stemming extension available on as many commonly used platforms as I
> could.)
>
> However, I'm having problems getting the extension to compile with VC++ 6
> on Windows 2000. (Which is the only Windows platform I use.) The problems
> seem to stem (no pun intended) from the fact that it seems to cling to
> ANSI/ISO C standards a bit more than gcc does.
>
> The main problem I'm getting: arrays with a length of zero. I'm not
> completely sure if this was part of the '85 C standard, as I don't have a
> copy readily available, but according to the C99 draft standard, arrays
> declared with constant expressions must be declared using integer values
> greater than zero. (The pertinent section of the draft standard is 6.7.5.2,
> para 1.)
>
> In many of the stemmers we see declarations and initializations like this
> (from the Dutch stemmer, line 17):
>
> static symbol s_0_0[0] = { };
>
> I never had problems before with code like this, as gcc basically ignores
> it, although if you compile with -pedantic if does produce the following
> warnings:
>
> dutch.c:17: warning: ISO C forbids zero-size array `s_0_0'
> dutch.c:17: warning: ISO C forbids empty initializer braces
>
> On VC++ 6, these warnings become errors:
>
> dutch.c(17) : error C2466: cannot allocate an array of constant size 0
> dutch.c(17) : error C2059: syntax error : '}'
>
> Is there anything that can be done to either shut VC++ up and make it
> compile (I'm so used to gcc now I'm at a loss with VC++'s options and make
> system) or to rework Snowball to eliminate these zero-sized arrays?
>
> Thx.
>
> J

_______________________________________________
Snowball-discuss mailing list
Snowball-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/snowball-discuss



This archive was generated by hypermail 2.1.3 : Thu Sep 20 2007 - 12:02:41 BST