Re: basic BASIC question

Liste des GroupesRevenir à co vms 
Sujet : Re: basic BASIC question
De : cross (at) *nospam* spitfire.i.gajendra.net (Dan Cross)
Groupes : comp.os.vms
Date : 02. Feb 2025, 04:57:42
Autres entêtes
Organisation : PANIX Public Access Internet and UNIX, NYC
Message-ID : <vnmqfm$79m$1@reader2.panix.com>
References : 1 2 3 4
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <679eb699$0$708$14726298@news.sunsite.dk>,
Arne Vajhøj  <arne@vajhoej.dk> wrote:
On 2/1/2025 6:38 PM, Craig A. Berry wrote:
 
On 2/1/25 3:00 PM, Arne Vajhøj wrote:
(in case someone wonder about C bool, then it is 8 bit!)
 
I don't think it has to be.  C99 says:
 
"An object declared as type _Bool is large enough to store the values 0
and 1."
 
8 bits are enough, but any integral type has enough bits.  "bool,"
"true," and "false" in stdbool.h are macros that can be overridden,
although doing so is described as "obsolescent" behavior.  It's probably
necessary because of the uses of bool before the standard had it.

Gone away in C23.  `bool`, `false`, and `true` are now keywords,
and thus reserved.  See n3220, sec 6.4.1 paras (1) and (2).
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf
 
I'm pretty sure I've seen bool defined as an int on VMS, but whether
that was something VAX C did for you or was just some what some program
did in the absence of anything available from the (old) compiler I don't
remember.
>
The C standard does not mandate 8 bit.

Correct.  The C standard doesn't really concern itself with the
concerete representation of data types; that's up to the
implementation.

Most of the time, this is given by an ABI.  For example, the
SVR4 ABI for x86_64 used on most modern Unix-y systems on that
platform defines the size of _Bool to be 1 byte.  See
https://gitlab.com/x86-psABIs/x86-64-ABI/-/jobs/artifacts/master/raw/x86-64-ABI/abi.pdf?job=build
(See figure 3.1, "Scalar Types", on page 17.)

Note that the OpenVMS calling standard for x86_64 closely
follows the System V ABI.
(https://vmssoftware.com/docs/VSI_CALLING_STD.pdf, sec C.2):

The VMS C documentation says 8 bit. Well - it says 1 byte
for whatever reason, but ...

The VMS ABI is derived from the System V ABI, and specifically
the AMD64 supplement, which defines "byte" to be an 8-bit
quantity in sec. 3.1.2:

|Within this specification, the term byte refers to a 8-bit
|object.

Note that the terms used in the SysV ABI for the larger
multibyte quantities are explicitly called out as things that
differ in the VMS Calling Standard, but this is understood to
mean nomenclature, not actual data layout.

If one include stdbool.h then bool is _Bool. From C 99.
>
Before C 99 then I think:
>
typedef int bool;
#define TRUE 1
#define FALSE 0
>
was common.

There were all sorts of variations before C99; this has led to
some headaches.  Beyond the obvious issue of symbol conflicts,
people have tried to play tricks with e.g. `enum`s, a la,

    typedef enum { false, true } bool;

but the issue here is that enums are really `int`s, and so so
if such things were used in, say, a `struct` in some
public-facing header, perhaps as part of a library that is
distributed in binary-form only,then you may have a breaking
change if linked against code that uses the newer ABI-mandated
representation.  For example, consider a struct such as:

    struct foo {
        int a;
        bool b;
        char c;
    };

On a system following the SysV AMD64 ABI, this is an 8-byte
type, with 4-byte alignment.  But using the enum trick, it's a
12-byte type, with 4-byte alignment.  Mismatched code beware.

(stdbool.h also defines true and false)

These are also now reserved keywords in C23.

- Dan C.


Date Sujet#  Auteur
31 Jan 25 * basic BASIC question62Arne Vajhøj
31 Jan 25 +* Re: basic BASIC question3Robert A. Brooks
31 Jan 25 i`* Re: basic BASIC question2Arne Vajhøj
31 Jan 25 i `- Re: basic BASIC question1Chris Townley
31 Jan 25 +- Re: basic BASIC question1jeffrey_dsi
31 Jan 25 +* Re: basic BASIC question35Dave Froble
31 Jan 25 i+* Re: basic BASIC question33Arne Vajhøj
31 Jan 25 ii+* Re: basic BASIC question30Dan Cross
31 Jan 25 iii+* Re: basic BASIC question27Arne Vajhøj
31 Jan 25 iiii+* Re: basic BASIC question11Dan Cross
1 Feb 25 iiiii+* Re: basic BASIC question2Craig A. Berry
1 Feb 25 iiiiii`- Re: basic BASIC question1Arne Vajhøj
1 Feb 25 iiiii`* Re: basic BASIC question8Arne Vajhøj
1 Feb 25 iiiii +* Re: basic BASIC question6Arne Vajhøj
1 Feb 25 iiiii i`* Re: basic BASIC question5Arne Vajhøj
1 Feb 25 iiiii i +- Re: basic BASIC question1Dan Cross
2 Feb 25 iiiii i `* Re: basic BASIC question3Craig A. Berry
2 Feb 25 iiiii i  `* Re: basic BASIC question2Arne Vajhøj
2 Feb 25 iiiii i   `- Re: basic BASIC question1Dan Cross
1 Feb 25 iiiii `- Re: basic BASIC question1Dan Cross
31 Jan 25 iiii`* Re: basic BASIC question15Arne Vajhøj
2 Feb 25 iiii +- Re: basic BASIC question1Lawrence D'Oliveiro
3 Feb 25 iiii `* Re: basic BASIC question13Simon Clubley
3 Feb 25 iiii  `* Re: basic BASIC question12Arne Vajhøj
3 Feb 25 iiii   +* Re: basic BASIC question10Lawrence D'Oliveiro
4 Feb 25 iiii   i`* Re: basic BASIC question9Arne Vajhøj
4 Feb 25 iiii   i +* Re: basic BASIC question7Lawrence D'Oliveiro
4 Feb 25 iiii   i i`* Re: basic BASIC question6Arne Vajhøj
4 Feb 25 iiii   i i +* Re: basic BASIC question2Lawrence D'Oliveiro
5 Feb 25 iiii   i i i`- Re: basic BASIC question1Arne Vajhøj
5 Feb 25 iiii   i i `* Re: basic BASIC question3Lawrence D'Oliveiro
5 Feb 25 iiii   i i  `* Re: basic BASIC question2Arne Vajhøj
5 Feb 25 iiii   i i   `- Re: basic BASIC question1Lawrence D'Oliveiro
4 Feb 25 iiii   i `- Re: basic BASIC question1Dan Cross
5 Feb 25 iiii   `- Re: basic BASIC question1Arne Vajhøj
31 Jan 25 iii`* Re: basic BASIC question2Chris Townley
31 Jan 25 iii `- Re: basic BASIC question1Dan Cross
1 Feb 25 ii`* Re: basic BASIC question2Dave Froble
1 Feb 25 ii `- Re: basic BASIC question1Arne Vajhøj
31 Jan 25 i`- Re: basic BASIC question1Chris Townley
31 Jan 25 +* Re: basic BASIC question20Simon Clubley
31 Jan 25 i+* Re: basic BASIC question17Arne Vajhøj
31 Jan 25 ii`* Re: basic BASIC question16Arne Vajhøj
31 Jan 25 ii +* Re: basic BASIC question14Dan Cross
3 Feb 25 ii i`* Re: basic BASIC question13Simon Clubley
3 Feb 25 ii i +* Re: basic BASIC question2John Dallman
3 Feb 25 ii i i`- Re: basic BASIC question1Lawrence D'Oliveiro
3 Feb 25 ii i +- Re: basic BASIC question1Dan Cross
6 Feb 25 ii i `* Re: basic BASIC question9Arne Vajhøj
6 Feb 25 ii i  +- Re: basic BASIC question1Arne Vajhøj
6 Feb 25 ii i  +* Re: basic BASIC question5Dan Cross
6 Feb 25 ii i  i`* Re: basic BASIC question4Arne Vajhøj
6 Feb 25 ii i  i +- Re: basic BASIC question1Dan Cross
6 Feb 25 ii i  i `* Re: basic BASIC question2Lawrence D'Oliveiro
7 Feb 25 ii i  i  `- Re: basic BASIC question1Arne Vajhøj
6 Feb 25 ii i  `* Re: basic BASIC question2Lawrence D'Oliveiro
7 Feb 25 ii i   `- Re: basic BASIC question1Arne Vajhøj
31 Jan 25 ii `- Re: basic BASIC question1Lawrence D'Oliveiro
1 Feb 25 i`* Re: basic BASIC question2Dave Froble
3 Feb 25 i `- Re: basic BASIC question1Simon Clubley
2 Feb 25 +- Re: basic BASIC question1Lawrence D'Oliveiro
2 Apr 25 `- Re: basic BASIC question1Johnny Billquist

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal