Sure.
I'll see your -O2 and raise you a -c ;)
It went like this:
$ gcc -c first.c -O2
$ gcc -c second.c -O2
$ gcc -c third.c -O2
No complaints from gcc whatsoever (unless I drop the -c, then ld complains about the undefined reference to main, which I think we all expect).
Just incase you expected one of them to fail (ex: as a control test), I verified that the original snippet from the configure script still causes an error on the system:
#########
$ cat << EOF > reference.c
> #include <locale.h>
> #include <curses.h>
> #include <wchar.h>
> int main(void) {
> const char *s = curses_version();
> wchar_t wch = L'w';
> setlocale(LC_ALL, "");
> resize_term(0, 0);
> addwstr(L"wide chars\n");
> addnwstr(&wch, 1);
> add_wch(WACS_DEGREE);
> return s != 0;
> }
> EOF
$ gcc reference.c -O2
reference.c: In function 'main':
reference.c:11:11: error: 'WACS_DEGREE' undeclared (first use in this function)
add_wch(WACS_DEGREE);
^
reference.c:11:11: note: each undeclared identifier is reported only once for each function it appears in
#########
Hope that helps.