Created
May 18, 2016 16:19
-
-
Save antirez/2b2c7d62606de5f2c3a35a5fde4811fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/tmp ➤ gcc foo.c -m32 | |
/tmp ➤ ./a.out | |
one offset: 0 | |
two offset: 4 | |
three offset: 12 | |
/tmp ➤ cat foo.c | |
#include <stdio.h> | |
#include <stdint.h> | |
struct foo { | |
int32_t one; | |
int64_t two; | |
int32_t three; | |
}; | |
int main(void) { | |
struct foo f; | |
printf("one offset: %lu\n",(unsigned long)&f.one - (unsigned long)&f); | |
printf("two offset: %lu\n",(unsigned long)&f.two - (unsigned long)&f); | |
printf("three offset: %lu\n",(unsigned long)&f.three - (unsigned long)&f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment