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

runtime: use __attribute__((__noreturn__)) instead of _Noreturn to avoid errors #431

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

kkysen
Copy link
Contributor

@kkysen kkysen commented Oct 7, 2024

_Noreturn doesn't exist before C11, and is deprecated in C23 (in favor or [[noreturn]]), so it's simpler just to use __attribute__((__noreturn__)) since we don't know what C version the headers will be compiled with.

@ayrtonm
Copy link
Contributor

ayrtonm commented Oct 7, 2024

I think we should replace our uses of _Noreturn with __attribute__((__noreturn__)) instead.

@kkysen
Copy link
Contributor Author

kkysen commented Oct 7, 2024

I think we should replace our uses of _Noreturn with __attribute__((__noreturn__)) instead.

In all cases, or just pre C11?

@ayrtonm
Copy link
Contributor

ayrtonm commented Oct 7, 2024

All cases. Glibc sometimes defines it as #define _Noreturn but I think that's just for old versions of gcc and unrecognized attributes should be ignored anyway. (Also I linked to our repo's glibc sysroot out of convenience but we don't use it on x86 in case that wasn't clear.)

@kkysen
Copy link
Contributor Author

kkysen commented Oct 8, 2024

All cases. Glibc sometimes defines it as #define _Noreturn but I think that's just for old versions of gcc and unrecognized attributes should be ignored anyway. (Also I linked to our repo's glibc sysroot out of convenience but we don't use it on x86 in case that wasn't clear.)

Should I do something like #define _Noreturn __attribute__((__noreturn__)) or just use __attribute__((__noreturn__)) inline in each case (just more verbose I guess)?

Also, can I just use __attribute__((noreturn))? It should be identical semantically (unless noreturn is #defined), just shorter.

@ayrtonm
Copy link
Contributor

ayrtonm commented Oct 8, 2024

I think __attribute__((__noreturn__)) inline is preferable since it has the lowest chance of breaking with different C libraries/compilers/unexpected macro definitions.

@kkysen kkysen force-pushed the kkysen/noreturn-pre-c11 branch from a060eff to e9260f2 Compare October 13, 2024 03:49
…o avoid errors

`_Noreturn` doesn't exist before C11, and is deprecated in C23 (in favor or `[[noreturn]]`),
so it's simpler just to use `__attribute__((__noreturn__))`
since we don't know what C version the headers will be compiled with.
@kkysen kkysen force-pushed the kkysen/noreturn-pre-c11 branch from e9260f2 to f3be8c3 Compare October 13, 2024 03:49
@kkysen kkysen changed the title runtime: #define _Noreturn as nothing before C11 to avoid errors runtime: use __attribute__((__noreturn__)) instead of _Noreturn to avoid errors Oct 13, 2024
@kkysen kkysen requested a review from ayrtonm October 13, 2024 03:50
Copy link
Contributor

@ayrtonm ayrtonm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kkysen kkysen merged commit 0177cc4 into main Oct 14, 2024
34 checks passed
@kkysen kkysen deleted the kkysen/noreturn-pre-c11 branch October 14, 2024 21:34
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