From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerry Van Baren Date: Wed, 08 Apr 2009 15:46:37 -0400 Subject: [U-Boot] use of C99 In-Reply-To: <20090408192832.8D48F8560EFB@gemini.denx.de> References: <4A0B9AAA-4714-4C27-84A7-22FCE4D91DDA@freescale.com> <20090408192832.8D48F8560EFB@gemini.denx.de> Message-ID: <49DCFF1D.6080006@ge.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Wolfgang, Wolfgang Denk wrote: > Dear Kumar Gala, > > In message <4A0B9AAA-4714-4C27-84A7-22FCE4D91DDA@freescale.com> you wrote: >> I was wondering if there was any reason we avoid C99 features in u- >> boot source. >> >> Specifically the ability to declare variables in the middle of >> functions. > > One reason is that I consider such code extremely ugly and hard to > read and understand. ACK. I don't expect to see variables spring into life in the middle of nowhere. >> There are a slew of places that we have something like: > ... >> #ifdef CONFIG_COOL_FEATURE >> u32 myvarrocks = foo * bar * bar; >> >> gd->neato = myvarrocks >> #endif > > It would be even better to avoid such #ifdef's, or at least the need > for such special local variables. Sometimes (often?) that is impossible. > Best regards, > > Wolfgang Denk If I'm not confused, I've seen block-local u-boot variables, has the advantages of being more distinctive and limits the lifetime of the variable. #ifdef CONFIG_COOL_FEATURE { u32 myvarrocks = foo * bar * bar; gd->neato = myvarrocks } #endif Is this an acceptable compromise? Best regards, gvb