On Tue, 22 Feb 2011, Dominique Pellé wrote: > On Hugh Sasse wrote: > > > I've been assisting a colleague with their C code, and he has > > learned to add semicolons at the end of statements too well. His > > current favourite mistake is to write > > if (expression == value); > > { > > do_something(); > > }; > > I frequently miss the trailing semicolon on the first line. So I [...] > > > Without using Vim, gcc can give a warning for such dubious code: > > $ cat foo.cpp | nl > 1 int main(int argc, char **argv) > 2 { > 3 int a; > 4 if (argc == 1); > 5 { > 6 a = 1; > 7 } > 8 a = 0; > 9 return a; > 10 } > > $ g++ -Wall -Wempty-body foo.cpp > foo.cpp: In function ?int main(int, char**)?: > foo.cpp:4: warning: suggest braces around empty body in an ?if? statement
Thanks. I'd probably stare at that and think "But the body isn't empty, it's got 'a=1;' in it!" :-) But I'd not noticed the -Wempty-body. > > -- Dominique > Thank you, Hugh -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php