Skip to content

Instantly share code, notes, and snippets.

@imaami
Created July 21, 2023 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imaami/82b3bfdda736e054dfe59a47f449f04a to your computer and use it in GitHub Desktop.
Save imaami/82b3bfdda736e054dfe59a47f449f04a to your computer and use it in GitHub Desktop.
Cursed sizeof.
#include <stdio.h>
#define sizeof(x) (!(#x[0]^0x27)?:sizeof(x))
#define q(x) printf("%-7s\t%zu\n", #x, x)
#define p(x) q(sizeof(x))
int main (void)
{
char s[7], c;
int i;
p(s);
p(c);
p(i);
p('x');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment