fork download
  1. #include <stdalign.h>
  2. #include <stdint.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. struct aligned {
  7. uint8_t a;
  8. uint8_t b;
  9. uint8_t c;
  10. };
  11.  
  12. int
  13. main(void)
  14. {
  15. struct aligned *ptr;
  16. struct aligned alignas(128) stack;
  17.  
  18. ptr = aligned_alloc(128, sizeof(*ptr));
  19. printf("ptr -> address: %p size: %u \n", ptr, sizeof(*ptr));
  20. printf("stack -> address: %p size: %u \n", &stack, sizeof(stack));
  21. return 0;
  22. }
Success #stdin #stdout 0s 5520KB
stdin
Standard input is empty
stdout
ptr   -> address: 0x55e3d1ca4080 size: 3 
stack -> address: 0x7ffcd4d25d00 size: 3