https://github.com/juliainterop/cenum.jl
C-compatible enum for Julia
https://github.com/juliainterop/cenum.jl
c enum julia
Last synced: 4 months ago
JSON representation
C-compatible enum for Julia
- Host: GitHub
- URL: https://github.com/juliainterop/cenum.jl
- Owner: JuliaInterop
- License: mit
- Created: 2019-01-17T14:15:15.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-23T05:47:12.000Z (over 2 years ago)
- Last Synced: 2025-04-08T21:42:33.641Z (about 1 year ago)
- Topics: c, enum, julia
- Language: Julia
- Homepage:
- Size: 37.1 KB
- Stars: 14
- Watchers: 8
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CEnum
[](https://github.com/JuliaInterop/CEnum.jl/actions)
[](https://codecov.io/gh/JuliaInterop/CEnum.jl)
[](https://juliahub.com/ui/Packages/CEnum/0gyUJ)
[](https://juliahub.com/ui/Packages/CEnum/0gyUJ)
[](https://juliahub.com/ui/Packages/CEnum/0gyUJ?t=2)
[](https://pkgs.genieframework.com?packages=CEnum)
This package provides a C-compatible enum for Julia.
```julia
julia> @enum Foo a = 1 b = 2 c = 1
ERROR: LoadError: ArgumentError: values for Enum Foo are not unique
Stacktrace:
[1] @enum(::LineNumberNode, ::Module, ::Any, ::Vararg{Any,N} where N) at ./Enums.jl:128
in expression starting at REPL[12]:1
julia> using CEnum
julia> @cenum(Bar, d = 1, e = 2, f = 1)
julia> d == f
true
```
## Credit
The original version is written by [SimonDanisch](https://github.com/SimonDanisch) in [this PR](https://github.com/JuliaInterop/Clang.jl/pull/162).