Last active
April 15, 2023 13:20
-
-
Save imaami/228f8f02bfc6e2576bbf8970b794a061 to your computer and use it in GitHub Desktop.
Backport of C23's typeof_unqual using GNU extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* If you compile with clang and `-Weverything' you'll probably want | |
* to use `-Wno-gnu-statement-expression-from-macro-expansion', too. | |
* | |
* Plain C18 version: | |
* https://gist.github.com/imaami/92b38f45142f8a8390fefa2d972bc63d | |
*/ | |
#define typeof_unqual(x) __typeof__(({ *(__typeof__(x) *)(void *)0; })) | |
int main(void) | |
{ | |
const int ci = 1; | |
typeof_unqual(ci) i1 = ci; | |
typeof_unqual(const int) i2 = ci; | |
i1 = 0; | |
i2 = 0; | |
return i1 + i2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment