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

Remove typedef's and bool enum #3

Open
DictumMortuum opened this issue May 30, 2016 · 1 comment
Open

Remove typedef's and bool enum #3

DictumMortuum opened this issue May 30, 2016 · 1 comment
Assignees

Comments

@DictumMortuum
Copy link
Owner

DictumMortuum commented May 30, 2016

Your types are unnecessary - just use unsigned char and int as the standard library would.

On the same topic, your enum bool is unnecessary because in C non-zero indicates the true state. You confirm that yourself because get() assumes that the value 1 is true. Everyone assumes this and so the type is redundant. Moreover it is also wrong because if I change your enum to

typedef enum{true=0, false} bool;
your function fails, even though it is logically a reasonable thing to do.

If you want to use a bool like that your should return one of its values explicitly:

return ((a >> pos) & 1) ? true : false;
but there is really no point in this. Just return an int as the standard library would.

@DictumMortuum DictumMortuum changed the title Remove typedef's Remove typedef's and bool enum May 30, 2016
@DictumMortuum DictumMortuum self-assigned this May 31, 2016
@DictumMortuum DictumMortuum reopened this Jun 1, 2016
@DictumMortuum
Copy link
Owner Author

This applies to external sort, too.

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

No branches or pull requests

1 participant