tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: using the interfaces in ctype.h

On 21-Apr-08, at 10:03 AM, Neil Booth wrote:

Greg A. Woods; Planix, Inc. wrote:-

I recommend the following slightly more portable technique for ctype.h:

        #define _CTYPE_MASK     ~(UINT_MAX << CHAR_BIT)

Hoho, if sizeof (char) == sizeof (int).

sizeof(char) is always "1". Are you suggesting that NetBSD might someday run on a CPU with 8-bit ints? Or pehaps you are suggesting that one day NetBSD might run on a 32-bit machine with 32-bit chars?

If the latter then I'm not sure what the problem will be since CHAR_BIT will be required to be defined as 32.

Regardless perhaps the mask should be defined as:

        #define _CTYPE_MASK     ~(~0UL << CHAR_BIT)

just to be pedantic.

                                        Greg A. Woods; Planix, Inc.

Home | Main Index | Thread Index | Old Index