Cesium icon indicating copy to clipboard operation
Cesium copied to clipboard

Is `_Bool` a primitive type?

Open ForNeVeR opened this issue 3 years ago • 2 comments
trafficstars

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 avatar Aug 06 '22 11:08 ForNeVeR

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

annchous avatar Oct 01 '22 16:10 annchous

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.

ForNeVeR avatar Oct 03 '22 18:10 ForNeVeR