From: Ben Warren <biggerbadderben@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] use of C99
Date: Wed, 08 Apr 2009 14:03:03 -0700 [thread overview]
Message-ID: <49DD1107.6090705@gmail.com> (raw)
In-Reply-To: <B85A65D85D7EB246BE421B3FB0FBB59301CC817CF8@dbde02.ent.ti.com>
Premi, Sanjeev wrote:
>> -----Original Message-----
>> From: u-boot-bounces at lists.denx.de
>> [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Timur Tabi
>> Sent: Thursday, April 09, 2009 1:55 AM
>> To: Jerry Van Baren
>> Cc: U-Boot-Users ML; Kumar Gala
>> Subject: Re: [U-Boot] use of C99
>>
>> On Wed, Apr 8, 2009 at 2:46 PM, Jerry Van Baren
>> <gerald.vanbaren@ge.com> wrote:
>>
>>
>>> ACK. I don't expect to see variables spring into life in
>>>
>> the middle of
>>
>>> nowhere.
>>>
>> I don't see what's wrong with that. The advantage is that the
>> variable is close to where it's being used, so that you can see the
>> context more easily.
>>
>>
>>> 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.
>>>
>> I don't see what the value is of limiting the lifetime of the
>> variable. The compiler isn't going to use that as a hint, anyway.
>> It's just going to use this for syntax checking. If you define and
>> initialize a variable at the top of the function, but don't use that
>> variable until a hundred lines later, the compiler is going to
>> initialize the variable when it's first used, not when the function is
>> first entered. Chances are it's not even going to define stack space
>> for it.
>>
>
> One of the biggest problem is uncontrolled variable definitions that
> gets even nasty when variables have same names with different types;
> though under different set of #ifdefs. Quite possible for commonly
> used variable names - i, ptr, tmp, etc.
>
>
I'm showing extreme ignorance here, but does C99 let you do this?
for (int i = 0; i < x ; i++) ?
Doing a lot of C++ has rotted my brain, but this is one thing I like.
regards,
Ben
next prev parent reply other threads:[~2009-04-08 21:03 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-08 18:51 [U-Boot] use of C99 Kumar Gala
2009-04-08 19:28 ` Wolfgang Denk
2009-04-08 19:46 ` Jerry Van Baren
2009-04-08 20:25 ` Timur Tabi
2009-04-08 20:46 ` Premi, Sanjeev
2009-04-08 20:57 ` Timur Tabi
2009-04-08 21:26 ` Premi, Sanjeev
2009-04-08 21:34 ` Timur Tabi
2009-04-08 21:03 ` Ben Warren [this message]
2009-04-08 21:23 ` Premi, Sanjeev
2009-04-08 20:52 ` Scott Wood
2009-04-08 21:01 ` Timur Tabi
2009-04-08 22:26 ` Scott Wood
2009-04-08 21:34 ` Wolfgang Denk
2009-04-08 21:38 ` Timur Tabi
2009-04-08 22:39 ` Graeme Russ
2009-04-08 22:45 ` Timur Tabi
2009-04-08 22:59 ` Wolfgang Denk
2009-04-08 23:09 ` Scott Wood
2009-04-08 22:28 ` Scott Wood
2009-04-08 21:27 ` Wolfgang Denk
2009-04-08 23:22 ` Larry Johnson
2009-04-08 23:40 ` Scott Wood
2009-04-09 4:27 ` Kumar Gala
2009-04-09 11:38 ` Jerry Van Baren
-- strict thread matches above, loose matches on Subject: below --
2009-04-09 1:53 Pink Boy
2009-04-09 2:12 ` Jerry Van Baren
2009-04-09 5:50 ` Wolfgang Denk
2009-04-09 13:27 ` Larry Johnson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49DD1107.6090705@gmail.com \
--to=biggerbadderben@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox