Programming question: missing braces around initializer
I have a bit of source code here with the following bit:
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,
[etc...]
'/',DAH,DIH,DIH,DAH,DIH,NIL,NIL,
0, NIL,NIL,NIL,NIL,NIL,NIL,NIL /* END MARKER */
};
Gcc warns me with:
morse.c:52: warning: missing braces around initializer
morse.c:52: warning: (near initialization for `MorseTable[0]')
Anyone know how to fix?
Thanks,
Joop
--
Joop Stakenborg PA4TU, ex-PA3ABA
<pa3aba@debian.org>
Linux Amateur Radio Software Database
http://radio.linux.org.au
Re: Programming question: missing braces around initializer
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?
Ray
--
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
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 imginations 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
Re: Programming question: missing braces around initializer
On Tue, Oct 05, 1999 at 14:23:38 +0200, Joop Stakenborg wrote:
> Morse MorseTable[]=
> {
> ' ',NIL,NIL,NIL,NIL,NIL,NIL,NIL,
Change to
{' ', {NIL,NIL,NIL,NIL,NIL,NIL,NIL}},
etc. The outer pair of curly braces is because the elements of the array are
structs, which aren't atomic; the inner pair is because the second member of
the struct is an array which isn't atomic.
HTH,
Ray
--
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 Re: Programming question: missing braces around initializer
On Tue, Oct 05, 1999 at 01:42:14PM +0200, J.H.M. Dassen Ray" wrote:
> On Tue, Oct 05, 1999 at 14:23:38 +0200, Joop Stakenborg wrote:
> > Morse MorseTable[]=
> > {
> > ' ',NIL,NIL,NIL,NIL,NIL,NIL,NIL,
>
> Change to
> {' ', {NIL,NIL,NIL,NIL,NIL,NIL,NIL}},
> etc. The outer pair of curly braces is because the elements of the array are
> structs, which aren't atomic; the inner pair is because the second member of
> the struct is an array which isn't atomic.
>
Yup! That's it.
No more warnings.
Thanks Ray,
> HTH,
> 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