fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #pragma pack(push, 16)
  5. struct Foo {
  6. int a;
  7. };
  8. #pragma pack(pop)
  9.  
  10. struct Foo1 {
  11. int a;
  12. } __attribute__((aligned(16)));
  13.  
  14. struct alignas(16) Foo2 {
  15. int a;
  16. };
  17.  
  18. int main() {
  19. cout << "sizeof(struct Foo) = " << sizeof(struct Foo) << endl;
  20. cout << "sizeof(struct Foo1) = " << sizeof(struct Foo1) << endl;
  21. cout << "sizeof(struct Foo2) = " << sizeof(struct Foo2) << endl;
  22. return 0;
  23. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
sizeof(struct Foo) = 4
sizeof(struct Foo1) = 16
sizeof(struct Foo2) = 16