I realized we can have "private" enums in C23, because they are
completed types. Values of E does not need to be at header file.
enum E : int;
struct X{
enum E e;
};
This creates a kind of encapsulation.
On 19/06/2024 04:24, Lawrence D'Oliveiro wrote:to
On Tue, 18 Jun 2024 08:09:13 -0300, Thiago Adams wrote:
This creates a kind of encapsulation.
Why not just use “int” or “unsigned int”? Why does the caller even need
know it’s an enum?
The advantage will be the type check at the implementation file (some compiler have extra type check for enuns) ...
... and clarity about the possible values accepted.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 429 |
Nodes: | 16 (2 / 14) |
Uptime: | 117:55:36 |
Calls: | 9,056 |
Calls today: | 3 |
Files: | 13,396 |
Messages: | 6,016,630 |