ANSI C rules for variable declaration
adam8157 at gmail.com
Fri Sep 21 01:57:02 EDT 2012
On Fri, Sep 21, 2012 at 10:15:01AM +0530, Lokesh Walase wrote:
> 0.I read that ANSI C rules for variable declaration says that one must declare
> the variables at the beginning of any scope block.
> C99 onwards we are allowed to declare variables as & how required.
> 1.NOW, my doubt is what happens in the actual "practical/real-world" codes that
> are written in industry.
> Do everyone *strictly* follow the ANSI C rules & declare the variables at the
> beginning of the scope ?
Yes, I do.
> 2.Also , why are we still following that old rule ? Is it so that old codes of
> 70s can be used with new codes ?
Because I like it. And I think it's better sometimes, for example,
variable declaration you mentioned, it's eaiser to trace all variables
by following the ANSI C standard.
ANSI C codes can be used with any modern compiler. And you can mix it
with other newer standards.
> 3.There must be some standard that all of us need to follow , so what are they
May be the standards followed by most people are gnu89(ANSI C with GCC
extensions) and C99.
PS, this is kind of out of topic in a kernel mail-list.
More information about the Kernelnewbies