Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is _Bool a primitive type? #179

Open
ForNeVeR opened this issue Aug 6, 2022 · 2 comments
Open

Is _Bool a primitive type? #179

ForNeVeR opened this issue Aug 6, 2022 · 2 comments
Labels
area:compiler Related to code compilation or type checking area:standard-support Related to the C standard support good-first-issue An issue considered simple enough for new contributors hacktoberfest status:help-wanted Open for contributors

Comments

@ForNeVeR
Copy link
Owner

ForNeVeR commented Aug 6, 2022

Right now, we have a following line in CTypeSystem.cs:

public IType Bool { get; } = new PrimitiveType(PrimitiveTypeKind.Int);

I'm not sure about that. In CLI, Bool's size is one byte, not four.

We'll have to check the standard to see whether _Bool is a primitive type we may use instead of PrimitiveTypeKind.Int here.

See // TODO[#179] in the code to fix this issue.

@ForNeVeR ForNeVeR added status:help-wanted Open for contributors area:standard-support Related to the C standard support area:compiler Related to code compilation or type checking good-first-issue An issue considered simple enough for new contributors labels Aug 6, 2022
@ForNeVeR ForNeVeR changed the title Is _Bool a primitive type? Is _Bool a primitive type? Aug 6, 2022
ForNeVeR added a commit to kant2002/Cesium that referenced this issue Aug 6, 2022
@annchous
Copy link

annchous commented Oct 1, 2022

According to the C17 Language Standard Draft referenced in your readme:

For each of the signed integer types, there is a corresponding (but different) unsigned integer type
(designated with the keyword unsigned) that uses the same amount of storage (including sign
information) and has the same alignment requirements. The type _Bool and the unsigned integer
types that correspond to the standard signed integer types are the standard unsigned integer types.

(Section 6.2.5, paragraph 6; page 31)

As I understood from here _Bool is a different unsigned integer type, but it corresponds with the standard unsigned integer type. Given this, I see no more suitable primitive type in Cesium than UnsignedInt.

So, there is the question: would we like to replace Int with UnsignedInt for better correspondence with the standard?

P.S. Sorry if I'm talking nonsense, I'm just getting started with your library <3

@ForNeVeR
Copy link
Owner Author

ForNeVeR commented Oct 3, 2022

As I understood from here _Bool is a different unsigned integer type, but it corresponds with the standard unsigned integer type.

Except there's no mention of "the standard unsigned integer type" in that paragraph. There are "the unsigned integer
types", a plural. So, I don't think that this part of the standard actually talks about the unsigned int (in C notation). It just tells us there's an unsigned integer type named _Bool.

Well, as I read it, at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:compiler Related to code compilation or type checking area:standard-support Related to the C standard support good-first-issue An issue considered simple enough for new contributors hacktoberfest status:help-wanted Open for contributors
Projects
None yet
Development

No branches or pull requests

2 participants