Thread (3 messages) flat view 3 messages, 2 authors, 2012-09-21

ANSI C rules for variable declaration

From: Lokesh Walase <hidden>
Date: 2012-09-21 18:36:10

On Fri, Sep 21, 2012 at 11:27 AM, Adam Lee [off-list ref] wrote:
On Fri, Sep 21, 2012 at 10:15:01AM +0530, Lokesh Walase wrote:
quoted
0.I read that ANSI C rules for variable declaration says that one must
declare
quoted
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
quoted
are written in industry.
Do everyone *strictly* follow the ANSI C rules & declare the variables
at the
quoted
beginning of the scope ?
Yes, I do.
quoted
2.Also , why are we still following that old rule ? Is it so that old
codes of
quoted
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.
quoted
3.There must be some standard that all of us need to follow , so what
are they
quoted
?
May be the standards followed by most people are gnu89(ANSI C with GCC
extensions) and C99.
Thanks for the reply Adam !
PS, this is kind of out of topic in a kernel mail-list.
Yeah , even I was sort of confused whether to aks this here or not.
Will take next time onwards :)
--
Regards,
Adam Lee
http://adam8157.info
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120922/3f326361/attachment.html 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help