Having installed gcc-3.1 on my system, I started recompiling things from the top down. When compiling xfree I got the following lines: gcc -c -march=i686 -O3 -pipe -ansi -I../common -I../loader -I../../../../../programs/Xserver/hw/xfree86/os-support -I../../../../../programs/Xserver/include -I../../../../../exports/include/X11 -I../../../../../lib/font/include -I../../../../.. -I../../../../../exports/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -DXF86CONFIG=\"XF86Config\" -DUSE_MODULES -DHAS_NCURSES -DPROJECT_ROOT=\"/usr/X11R6\" -DXF86CONFIGDIR=\"/usr/X11R6/lib/X11\" text-mode.c In file included from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.1/include/ncurses.h:86, from text-mode.c:35: /usr/include/unctrl.h:57: parse error before "unctrl" And found similar errors with other things (such as `make menuconfig` for kernel compiles). The file belongs to ncurses.
I've also experienced the same problem, but not always. I've managed to compile the kernel (make menuconfig) and compile xfree without problem. But at some point I was emerging more packages, and "emerge -p" told me that it would emerge ncurses again (it was marked as an "R"). The next package on the list was "dialog". I didn't pay much attention then, but only after that moment that the problems with ncurses started. The dialog never got emerged safely.
Removing /usr/lib/gcc-lib/i686-pc-linux-gnu/3.1/include/{curses,ncurses}.h eliminates the problem. Those are headers which were processed by "fixincludes" which attempts to fix non-standard declarations, but somehow this really shouldn't happen as it breaks when new packages are installed. On my system there are a few more headers from other packages in that directory which deserve attention. One is from zlib and the other is from the linux kernel headers! I think that this bug should be considered blocker/critical, but I don't have the previledges to do it.
this was a problem with gcc installing duplicate headers for ncurses that sucked, fixed.