fork download
  1. #include <iostream>
  2. #include <cstdint>
  3. #include <cstddef>
  4.  
  5. using namespace std;
  6.  
  7. using al64_uint32_t = uint32_t __attribute__((aligned(64)));
  8.  
  9. struct Foo
  10. {
  11. uint32_t a;
  12. uint32_t b;
  13. uint32_t c;
  14. uint32_t d;
  15. };
  16.  
  17. struct Bar
  18. {
  19. uint32_t a;
  20. uint32_t b;
  21. al64_uint32_t c;
  22. uint32_t d;
  23. };
  24.  
  25.  
  26. int main()
  27. {
  28.  
  29. cout << sizeof(al64_uint32_t) << endl;
  30. cout << sizeof(Foo) << endl;
  31. cout << sizeof(Bar) << endl;
  32.  
  33. cout << "a: " << offsetof(Bar, a) << endl;
  34. cout << "b: " << offsetof(Bar, b) << endl;
  35. cout << "c: " << offsetof(Bar, c) << endl;
  36. cout << "d: " << offsetof(Bar, d) << endl;
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
4
16
128
a: 0
b: 4
c: 64
d: 68