Sample conformant, clean <c...> headers
scott snyder
snyder@fnal.gov
Mon Jun 4 17:25:00 GMT 2001
hi -
Benjamin Kosnik <bkoz@redhat.com> writes:
> I would like feedback on Stephen's approach. I think it's sound, but am
> interested in hearing from Nathan and others.
>
> Nathan? Care to comment? Scott?
The problem i see is that the following test doesn't seem to work
(with the 20010529 version of gcc 3.0):
-------------------------------------
#include <cctype>
#include <ctype.h>
using namespace std;
int
main(int argc, char* argv[])
{
//using std::isalpha;
int k = 1;
if (isalpha('k'))
{
k = 0;
}
return k;
}
-------------------------------------
(This is Stephen's test program, but with `using namespace std' instead
of the `using std::isalpha'.)
If i try to compile this with Stephen's std_cctype.h header (creating
a local `cctype' that includes it), i get:
$ g++ -c -I. ./test_cctype.cc
test_cctype.cc: In function `int main(int, char**)':
test_cctype.cc:12: call of overloaded `isalpha(char)' is ambiguous
/usr/include/ctype.h:92: candidates are: int isalpha(int)
std_cctype.h:60: int std::isalpha(int)
I think this comes back to the requirement that for names from the
C headers, ::foo and std::foo are supposed to be the _same_ function.
As far as i can tell, the example above is allowed by the standard,
and should compile. Having that not work is likely to break lots
of real-world code.
Am i missing something here?
thanks,
sss
More information about the Libstdc++
mailing list