Skip to content

Commit 29c6557

Browse files
committed
msvc: handle DEVELOPER=1
We frequently build Git using the `DEVELOPER=1` make setting as a shortcut to enable all kinds of more stringent compiler warnings. Those compiler warnings are relatively specific to GCC, though, so let's try our best to translate them to the equivalent options to pass to MS Visual C++'s `cl.exe`. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent f3b9a23 commit 29c6557

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

compat/vcbuild/scripts/clink.pl

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,52 @@
5757
push(@lflags, $arg);
5858
} elsif ("$arg" =~ /^-[Rl]/) {
5959
# eat
60+
} elsif ("$arg" eq "-Werror") {
61+
push(@cflags, "-WX");
62+
} elsif ("$arg" eq "-Wall") {
63+
# cl.exe understands -Wall, but it is really overzealous
64+
push(@cflags, "-W4");
65+
# disable the "signed/unsigned mismatch" warnings; our source code violates that
66+
push(@cflags, "-wd4018");
67+
push(@cflags, "-wd4245");
68+
push(@cflags, "-wd4389");
69+
# disable the "unreferenced formal parameter" warning; our source code violates that
70+
push(@cflags, "-wd4100");
71+
# disable the "conditional expression is constant" warning; our source code violates that
72+
push(@cflags, "-wd4127");
73+
# disable the "const object should be initialized" warning; these warnings affect only objects that are `static`
74+
push(@cflags, "-wd4132");
75+
# disable the "function/data pointer conversion in expression" warning; our source code violates that
76+
push(@cflags, "-wd4152");
77+
# disable the "non-constant aggregate initializer" warning; our source code violates that
78+
push(@cflags, "-wd4204");
79+
# disable the "cannot be initialized using address of automatic variable" warning; our source code violates that
80+
push(@cflags, "-wd4221");
81+
# disable the "possible loss of data" warnings; our source code violates that
82+
push(@cflags, "-wd4244");
83+
push(@cflags, "-wd4267");
84+
# disable the "array is too small to include a terminating null character" warning; we ab-use strings to initialize OIDs
85+
push(@cflags, "-wd4295");
86+
# disable the "'<<': result of 32-bit shift implicitly converted to 64 bits" warning; our source code violates that
87+
push(@cflags, "-wd4334");
88+
# disable the "declaration hides previous local declaration" warning; our source code violates that
89+
push(@cflags, "-wd4456");
90+
# disable the "declaration hides function parameter" warning; our source code violates that
91+
push(@cflags, "-wd4457");
92+
# disable the "declaration hides global declaration" warning; our source code violates that
93+
push(@cflags, "-wd4459");
94+
# disable the "potentially uninitialized local variable '<name>' used" warning; our source code violates that
95+
push(@cflags, "-wd4701");
96+
# disable the "unreachable code" warning; our source code violates that
97+
push(@cflags, "-wd4702");
98+
# disable the "potentially uninitialized local pointer variable used" warning; our source code violates that
99+
push(@cflags, "-wd4703");
100+
# disable the "assignment within conditional expression" warning; our source code violates that
101+
push(@cflags, "-wd4706");
102+
# disable the "'inet_ntoa': Use inet_ntop() or InetNtop() instead" warning; our source code violates that
103+
push(@cflags, "-wd4996");
104+
} elsif ("$arg" =~ /^-W[a-z]/) {
105+
# let's ignore those
60106
} else {
61107
push(@args, $arg);
62108
}

0 commit comments

Comments
 (0)