Why is unit an alias of int in sail.h #356
martinberger
started this conversation in
General
Replies: 2 comments 2 replies
-
|
Beta Was this translation helpful? Give feedback.
2 replies
-
On Fri, 27 Oct 2023 at 20:50, Alasdair Armstrong ***@***.***> wrote:
If the goal is to have a guaranteed zero-width type, I don't know of a
good way to do that in standard C. I think void is a bit too special to be
used here, as it's more like a thing with no size rather than a thing with
zero size, and it can't really be used as a regular type. Something like enum
unit {UNIT} might be the closest logically, but I think that would still
end up being represented as an int with UNIT = 0.
Empty structs are not ISO C, but they are allowed in a GCC (and presumably
also Clang) extension:
https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Empty-Structures.html
I don't know whether there are social or technical reasons why we'd want to
avoid using them for Sail->C, if there's a strong argument for them.
Peter
… —
Reply to this email directly, view it on GitHub
<#356 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABFMZZWG4AFSLGIFOAKAVXDYBQF65AVCNFSM6AAAAAA6SQSFZCVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TIMBXGEZTI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is the rationale behind making
unit
an alias ofint
? In sail.h we find:I would have expected
unit
to be something likestruct unit {};
which, I think, is used in C++.Beta Was this translation helpful? Give feedback.
All reactions