On Sun, Jan 9, 2022 at 1:46 PM Harald Anlauf via Fortran <fortran@gcc.gnu.org> wrote: > > Dear all, > > while working on a PR related to kind=4 character issues, I saw the > following in gfortran.h: > > > /* We need to store source lines as sequences of multibyte source > characters. We define here a type wide enough to hold any multibyte > source character, just like libcpp does. A 32-bit type is enough. */ > > #if HOST_BITS_PER_INT >= 32 > typedef unsigned int gfc_char_t; > #elif HOST_BITS_PER_LONG >= 32 > typedef unsigned long gfc_char_t; > #elif defined(HAVE_LONG_LONG) && (HOST_BITS_PER_LONGLONG >= 32) > typedef unsigned long long gfc_char_t; > #else > # error "Cannot find an integer type with at least 32 bits" > #endif > > > This seems to have been introduced by FX, but I do not really > understand it. Can't we use a fixed and platform-independent > type that can hold wide chars? Isn't a 32-bit / 4-byte type > sufficient?
I suspect HOST_BITS_PER_INT will always be 32bit for all hosts GCC will be supported but who knows. The point of the check is to find a type which is at least 32bits enough to hold the wide character. HOST_BITS_PER_* are defined in hwint.h: #define HOST_BITS_PER_CHAR CHAR_BIT #define HOST_BITS_PER_SHORT (CHAR_BIT * SIZEOF_SHORT) #define HOST_BITS_PER_INT (CHAR_BIT * SIZEOF_INT) #define HOST_BITS_PER_LONG (CHAR_BIT * SIZEOF_LONG) #define HOST_BITS_PER_PTR (CHAR_BIT * SIZEOF_VOID_P) Where SIZEOF_* are defined while doing a configure and CHAR_BIT is defined in limits.h which is defined as a preprocessor constant. Does that help you understand the code better? Thanks, Andrew Pinski > > Thanks for any enlightenment, > Harald >