isspace from
<cctype>)
Glibc 2.0.x and 2.1.x define the
<ctype.h>
-functionality as macros (isspace, isalpha etc.). Libstdc++-v3
"shadows" these macros as described in the section about
c-headers.
Older implementations of libstdc++ (g++-2 for egcs 1.x and g++-3
for gcc 2.95.x), however, keep these functions as macros, and so it
is not back-portable to use fully qualified names. For example:
#include <cctype>
int main() { std::isspace('X'); }
will result in something like this (unless using g++-v3):
std:: (__ctype_b[(int) ( ( 'X' ) )] & (unsigned short int)
_ISspace )  ;
One solution I can think of is to test for -v3 using
autoconf-macros, and define macros for each of the C-functions
(maybe that is possible with one "wrapper" macro as well ?).
Another solution which would fix g++ is to tell the user to modify a
header-file so that g++-2 (egcs 1.x) and g++-3 (gcc 2.95.x) define a
macro which tells <ctype.h> to define functions
instead of macros:
// This keeps isalnum, et al from being propagated as macros.
#if __linux__
#define __NO_CTYPE 1
#endif
[ now include <ctype.h> ]
Another problem arises if you put a using namespace
std; declaration at the top, and include <ctype.h>. This will result in
ambiguities between the definitions in the global namespace
(<ctype.h>) and the
definitions in namespace std::
(<cctype>).
The solution to this problem was posted to the libstdc++-v3
mailing-list:
Benjamin Kosnik bkoz@redhat.com writes:
--enable-cshadow-headers is currently broken. As a result, shadow
headers are not being searched....
This is now outdated, but gcc 3.0 still does not have fully
compliant "shadow headers".
