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

Re: Programming question: missing braces around initializer



On Tue, Oct 05, 1999 at 12:22:57PM +0200, J.H.M. Dassen Ray" wrote:
> On Tue, Oct 05, 1999 at 11:58:23 +0200, Joop Stakenborg wrote:
> > morse.c:52: warning: missing braces around initializer
> 
> > Anyone know how to fix?
> 
> Just a guess, perhaps Morse is a 2 or more dimensional array type rather
> than a one-dimensional one, and you need to add braces for the rows?

No, don't think so...

Here is a bit from the code:

---------------------------------------------------------------------------
/* declaration of Morse */

Morse MorseTable[]=
{
        ' ',NIL,NIL,NIL,NIL,NIL,NIL,NIL,
        'A',DIH,DAH,NIL,NIL,NIL,NIL,NIL,
        'B',DAH,DIH,DIH,DIH,NIL,NIL,NIL,
        'C',DAH,DIH,DAH,DIH,NIL,NIL,NIL,

        [etc...]

        '0',DAH,DAH,DAH,DAH,DAH,NIL,NIL,
        '?',DIH,DIH,DAH,DAH,DIH,DIH,NIL,
        '/',DAH,DIH,DIH,DAH,DIH,NIL,NIL,
        0,  NIL,NIL,NIL,NIL,NIL,NIL,NIL /* END MARKER */
};

/* structure called Morse */

typedef struct
{
        char code;
        enum
        {
               NIL,
               DIH,
               DAH,
        } data[7];
} Morse;

/* example of how table is called */

Morse *CharToMorse(char c)
{
	int ct=0;
        while(MorseTable[ct].code)
        {
                  if(MorseTable[ct].code==c)
                              return(&MorseTable[ct]);
                  ct++;
        }
        return(NULL);
}
-----------------------------------------------------------------------

Looks one-dimensional to me.....

The warnings says:
$ gcc -Wall morse.c
morse.c:52: warning: missing braces around initializer
morse.c:52: warning: (near initialization for `MorseTable[0]')

line 52 is: ' ',NIL,NIL,NIL,NIL,NIL,NIL,NIL, (see above)
> 
> Ray
> -- 

Groetjes,

Joop

> LEADERSHIP  A form of self-preservation exhibited by people with auto-
> destructive imaginations in order to ensure that when it comes to the crunch 
> it'll be someone else's bones which go crack and not their own.       
> - The Hipcrime Vocab by Chad C. Mulligan    
> 
> 

-- 

 Joop Stakenborg PA4TU, ex-PA3ABA 
      <pa3aba@debian.org>
 Linux Amateur Radio Software Database
    http://radio.linux.org.au


Reply to: