C considered dangerous
C considered dangerous
Posted Aug 30, 2018 12:30 UTC (Thu) by error27 (subscriber, #8346)In reply to: C considered dangerous by mina86
Parent article: C considered dangerous
drivers/video/fbdev/sm501fb.c: In function ‘sm501fb_start’:
drivers/video/fbdev/sm501fb.c:1613:2: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int k = 0; k < (256 * 3); k++)
^~~
It's an aesthetic preference. https://lkml.org/lkml/2005/12/13/223
One thing that I do is I have "foo->bar" and I want to find out what type it is, so i highlight "bar" then I scroll to the top of the function where "foo" is declared and then I use cscope to jump to the type definition. So it's nice if you kind of know all the variables are declared at the start of the function.