Re: [PATCH 2/2] test/hash: Fix warning in preprocessor symbol evaluation
From: George Spelvin
Date: Sun May 29 2016 - 15:07:20 EST
> But here's an alternative. Geert, what do you think of this?
Never mind; that doesn't work. Plain gcc-4.9 passes, it, but it's the
"-Wundef" flag that the kernel uses that triggers it.
So we're back to Geert's original suggestion.
Acked-by: George Spelvin <linux@xxxxxxxxxxxxxxxxxxx>
==>$ cat foo.c
#ifndef FOO
This is a test.
#elif FOO == 1
This is another test
#elif FOO + 0 == 1
who knows
#endif
==>$ gcc-6 -W -Wall -Wundef -E foo.c
# 1 "foo.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "foo.c"
This is a test.
==>$ gcc-4.9 -W -Wall -Wundef -E foo.c
# 1 "foo.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "foo.c"
foo.c:3:7: warning: "FOO" is not defined [-Wundef]
#elif FOO == 1
^
foo.c:5:7: warning: "FOO" is not defined [-Wundef]
#elif FOO + 0 == 1
^
This is a test.