Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enums #57

Open
elikaski opened this issue Apr 6, 2021 · 3 comments
Open

Add enums #57

elikaski opened this issue Apr 6, 2021 · 3 comments
Labels
good first issue Good for newcomers

Comments

@elikaski
Copy link
Owner

elikaski commented Apr 6, 2021

Could be nice to have user-defined enums

enum RESULT {
   SUCCESS=0,
   FAILURE=1,
   UNKNOWN=2
}

That can be used inside switch-case as literals:

switch (result) {
   case SUCCESS: ...
   case FAILURE: ....
   case UNKNOWN: ...
}

And as parameters to functions

void foo(RESULT r) {
   if (r == SUCCESS) ...
}
@elikaski elikaski added the good first issue Good for newcomers label Apr 6, 2021
@NeeEoo
Copy link
Contributor

NeeEoo commented Apr 6, 2021

#define would work like this. Enums i think, works like this RESULT.FAILURE

@elikaski
Copy link
Owner Author

elikaski commented Apr 6, 2021

There are several ways to use enums, I don't mind which one we choose as long as it works 😄

@NeeEoo
Copy link
Contributor

NeeEoo commented Apr 7, 2021

It would probably be better to just replace RESULT.FAILURE with 1 in the compilation process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants