http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58952
Bug ID: 58952
Summary: Construct "std::getchar()" rejected when getchar is
macro in C library
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: michael at talamasca dot ocis.net
On my system, the following C++ code refuses to compile:
#include <cstdio>
int foo (void)
{
return std::getchar();
}
The immediate cause is that getchar() is a macro in my underlying C library
(uClibc-0.9.33.2). Changing it to (std::getchar)() works.
Looking at the /usr/include/c++/4.8.2/cstdio file, there are a number of #undef
directives apparently intended to prevent similar problems with other stdio
functions. But there is no #undef for getchar.
GNU automake's test suite uses this construct as part of a test to make sure
that a C++ file generated using yacc actually reaches a C++ compiler and not a
C one.