Sujet : Re: on allowing "int a" definition everywhere
De : already5chosen (at) *nospam* yahoo.com (Michael S)
Groupes : comp.lang.cDate : 21. Aug 2024, 14:54:54
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240821165454.000049f8@yahoo.com>
References : 1 2 3 4 5 6
User-Agent : Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32)
On Wed, 21 Aug 2024 10:01:12 -0300
Thiago Adams <
thiago.adams@gmail.com> wrote:
For this type of error you need my static analyzer. (cake) :D
Unnecessary. MSVC -W4 gives a warning.
#include <cstdio>
void foo()
{
FILE* f = fopen("file1.txt", "r");
if (FILE* f = fopen("file2.txt", "r")) {
fclose(f);
}
if (f)
fclose(f);
}
scopes.cpp(6): warning C4456: declaration of 'f' hides previous local
declaration scopes.cpp(5): note: see declaration of 'f'