Search code examples
c++cwidechar

Is there a reason for any C or C++ compiler to not define wctrans_t and wctype_t as the type wchar_t?


Actually, I'm working on a comparison of data types between programming languages, and here is my problem when reading the C and C++ standards.

Quoted from C11,

wctrans_t is a scalar type that can hold values which represent locale-specific character mappings

wctype_t is a scalar type that can hold values which represent locale-specific character classifications

The phrase a scalar type indicates that C11 does not restrict wctrans_t and wctype_t to be a specific scalar type.

My GCC 4.8 of MinGW implements wctrans_t and wctype_t as a typedef for wchar_t, and I can't think there is a reason for any other C compilers to not define them as it is.

Could somebody proof otherwise, or give a possibility for that to happen?


Solution

  • I am surprised someone defined them as wchar_t, neither wctype_t nor wctrans_t have anything to do with characters.

    Both platforms I use define them as something else:

    aix~$ grep wctype_t /usr/include/*h | grep typedef 
    /usr/include/ctype.h:   typedef unsigned int    wctype_t;
    
    aix~$ grep wctrans_t /usr/include/*h | grep typedef 
    /usr/include/wctype.h:typedef wint_t (*wctrans_t)();
    
    
    solaris~$ grep wctype_t /usr/include/*h | grep typedef 
    /usr/include/wchar.h:typedef    int     wctype_t;
    
    solaris~$ grep wctrans_t /usr/include/*/*h | grep typedef
    /usr/include/iso/wctype_iso.h:typedef unsigned int      wctrans_t;