From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua1-x936.google.com (mail-ua1-x936.google.com [IPv6:2607:f8b0:4864:20::936]) by sourceware.org (Postfix) with ESMTPS id DC3363891C07 for ; Sun, 9 Jan 2022 22:01:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DC3363891C07 Received: by mail-ua1-x936.google.com with SMTP id x33so19001595uad.12 for ; Sun, 09 Jan 2022 14:01:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=u8OREtLHvHdTsqGCvcB9qDdc1395wpcK01nL2Zxe9u4=; b=pTZf6LDvxr2LzpSZZgTgWots6ZueozgH6lQAfRF0gIhVSJaMC19+KtEg8rVQo4OOqp cnwmmstPwKGjFolTwMwLxGkUaSgMmEThpEhV3jmk0tjjEvLakLW6R8iyKcLtndZu4fDf u9is3HlJLXuoapr+EIJCLlmct50MaNqBKN/4sCgNfdLGQj39n2asIA9fJN6PgVWIsi2Y zZWbt1Y2mWqbcUGA/Vbr7HkNpiBmb2/p8pxy8Oay5afl/3K+Qc3s2n4OzXn2/tduROCR zxuV/9KkpMqNNhO5EnYMmUKyz2m/WhqgfuZ8DC8eWnmswnsluyfMgp7i/3wkbDhaj6AO pEWQ== X-Gm-Message-State: AOAM533/XEQwlRpCa6ovMNccFnuCtimMy15xiV3o8bDHBYCeXrvoNhUz 1f6k9Maj59UEcMewax9uSqTkCWixTgnO9mrQ4vI= X-Google-Smtp-Source: ABdhPJx568E/Uyp2HaCeaIzZsarpt2DapRnjok1EaQ3NzdRr1sgUL0GzGKsfvutJVuHUZUf6tlhhfJI3fVHscEMUOcw= X-Received: by 2002:a67:f305:: with SMTP id p5mr24341616vsf.8.1641765670257; Sun, 09 Jan 2022 14:01:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Andrew Pinski Date: Sun, 9 Jan 2022 14:00:57 -0800 Message-ID: Subject: Re: gfc_char_t To: Harald Anlauf Cc: fortran@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Jan 2022 22:01:12 -0000 On Sun, Jan 9, 2022 at 1:46 PM Harald Anlauf via Fortran 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 >