Skip to content

Instantly share code, notes, and snippets.

@electroCutie
Last active March 11, 2019 11:12
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 electroCutie/55af3f9b0ca95487c1f4e5d1c9ddb94f to your computer and use it in GitHub Desktop.
Save electroCutie/55af3f9b0ca95487c1f4e5d1c9ddb94f to your computer and use it in GitHub Desktop.
#include <stdint.h>
#include <stdio.h>
#include <printf.h>
#define _stride(_type) ({ \
_type* _t = (_type*) 0; \
(uint64_t) (_t+1); \
})
struct st {
char c;
double d;
};
int main(){
printf("%lu\n", _stride(char));
printf("%lu\n", _stride(int));
printf("%lu\n", _stride(long));
printf("%lu\n", _stride(unsigned long long));
printf("%lu\n", _stride(float));
printf("%lu\n", _stride(double));
printf("%lu\n", _stride(struct st));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment