Messages in this thread | | | From | David Laight <> | Subject | RE: [PATCH] Makefile: Yes. Finally remove '-Wdeclaration-after-statement' | Date | Tue, 18 Aug 2020 08:56:22 +0000 |
| |
> I'm a big fan of -Wdeclaration-after-statement and I think C++ style > mixed variables/statements code has several disadvantages:
Agreed. Personally I think declarations should either be either right at the top of a function or in a very small code block.
Otherwise they are annoying to find.
You also get very hard to spot bugs unless -Wshadow is enabled (I can't remember if the linux kernel has it enabled).
C++ (sort of) has to allow definitions in the middle of code blocks because it doesn't allow uninitialised variables - so definitions are best delayed until the copy-constructor can be used.
David
- Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
| |