Skip to content

Commit 9e78f8b

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 39d0e05 commit 9e78f8b

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

compat/vcbuild/scripts/clink.pl

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

0 commit comments

Comments
 (0)