Skip to content

Instantly share code, notes, and snippets.

@imaami
Created April 15, 2023 13:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imaami/92b38f45142f8a8390fefa2d972bc63d to your computer and use it in GitHub Desktop.
Save imaami/92b38f45142f8a8390fefa2d972bc63d to your computer and use it in GitHub Desktop.
Backport of C23's typeof_unqual in plain C18
#define typeof_unqual(x) __typeof__(((void)1, *(__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