www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/07/08:49:11

Xref: news2.mv.net comp.os.msdos.djgpp:6855 gnu.gcc.help:7739
From: mac AT greatdane DOT webnexus DOT com (Mike McNamara)
Newsgroups: gnu.gcc.help,comp.os.msdos.djgpp
Subject: Re: array init warning
Date: 06 Aug 1996 01:50:52 GMT
Organization: WebNexus Communications
Lines: 38
Message-ID: <MAC.96Aug5185052@greatdane.webnexus.com>
References: <xbubugwfp9o DOT fsf AT hp403 DOT den DOT mmc DOT com>
Reply-To: mac AT silicon-sorcery DOT com
NNTP-Posting-Host: greatdane.webnexus.com
In-reply-to: haack@hp403.den.mmc.com's message of 31 Jul 1996 08:53:07 -0600
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <xbubugwfp9o DOT fsf AT hp403 DOT den DOT mmc DOT com> haack AT hp403 DOT den DOT mmc DOT com (Brad R. Haack) writes:

   I'm using the djgpp port of gcc 2.7.2 on a pentium.

   Why does this style of initialization result in a warning (missing
   braces around initializer for`junk[0]') ?  It seems like a reasonable
   and safe style to me.  What flag would I use to turn this off?  I'm
   using -Wall currently.

     int junk[2][3] = { 1, 2, 3,
			4, 5, 6} ;

A doubly dimensioned array requires a doubly depth initialization array: 

int junk[2][3] = 
{ 
  {1, 2, 3},
  {4, 5, 6}
};

This gives you other benies like:

int junk[2][3] = 
{ 
  {1 },
  {4, 5, 6},
  {3, 2	},
} ;

elided initializers defaluting to zero.

besides, it's the standard!

-mac
--
Michael McNamara     Silicon Sorcery  <http://www.silicon-sorcery.com>
Get my emacs mode (subscribe for free updates!) at 
	            <http://www.silicon-sorcery.com/verilog-mode.html>

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019