This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Array Initialization warnings


>Hi David,
>
> The compiler is quite right, your initialiser is for
>an int JPEG_MRK_NTSC[16].
>
>Try something like;
>
>int JPEG_MRK_NTSC[4][4] =
> {
> {0x01, 0x02, 0x03, 0x04},
> {0x05, 0x06, 0x07, 0x08},
> {0x09, 0x0a, 0x0b, 0x0c},
> {0x0d, 0x0e, 0x0f, 0x00}
> };
>
>yours sincerely,
>
>bjorn

Thanks bjorn, indeed that eliminates the warnings and your explanation makes perfect sense.  Is it an accident...or just lucky,
that the array members are initialized correctly regardless of the way that I write the code?  I am porting this code from 
windows and the same warning did not appear in the msvc compiler.  Is this a compiler dependent issue and am I just asking
for trouble if the brackets are left out?

Thanks again!!

David Stroupe wrote:
> 
> When I compile this line of code
> 
> int JPEG_MRK_NTSC[4][4] =
> {
> 0x01, 0x02, 0x03, 0x04,
> 0x05, 0x06, 0x07, 0x08,
> 0x09, 0x0a, 0x0b, 0x0c,
> 0x0d, 0x0e, 0x0f, 0x00
> };
> 
>  with the -Wall option, I get the following warnings
> 
> vis.c:264: warning: missing braces around initializer
> vis.c:264: warning: (near initialization for `JPEG_MRK_NTSC[0]')
> 
> If I look at the values of the array members during execution, they are
> correct.
> 
> Is this array really being initialized correctly?
> Are the warnings correct?
> 
> Is there a way to 'turn off' these particular warnings with a compiler
> directive?
> 
>

-- 
Best regards,
David Stroupe
Keyed-Up Software
5307 Faireast Court
Arlington, Texas 76018-1683
817/557-4903 voice
817/472-0408 fax




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]