Skip to content

Conversation

xanathar
Copy link
Contributor

Having a repr(C) enum is syntactically perfectly legal and used, even though the specs are not clear on what underlying type is used for such an enum. Checking both documentation online and testing with several OS (macOS, Windows, Linux) and architectures (x86, x86-64 and aarch64) u32 (i.e. uint) seems to be the correct choice on all platforms where C# interop is reasonable to happen.

Still, without this a repr(C) enum would produce code that wouldn't compile at all.

	Having a `repr(C)` enum is syntactically perfectly legal and used,
	even though the specs are not clear on what underlying type is used
	for such an enum. Checking both documentation online and testing
	with several OS (macOS, Windows, Linux) and architectures
	(x86, x86-64 and aarch64) `u32` (i.e. `uint`) seems to be the
	correct choice on all platforms where C# interop is reasonable to
	happen.
	Still, without this a `repr(C)` enum would produce code that
	wouldn't compile at all.
@neuecc
Copy link
Member

neuecc commented Sep 20, 2023

In Rustnomicon says, it is "best guess",
However it's much better than not being able to compile.
Thank you!

@neuecc neuecc merged commit 6c04d9d into Cysharp:main Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants