История изменений
Исправление
cumvillain,
(текущая версия)
:
$ cat test.c
#include <stdalign.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
struct aligned {
uint8_t a;
uint8_t b;
uint8_t c;
};
int
main(void)
{
struct aligned *ptr;
struct aligned alignas(128) stack;
ptr = aligned_alloc(128, sizeof(*ptr));
printf("ptr -> address: %p size: %u \n", ptr, sizeof(*ptr));
printf("stack -> address: %p size: %u \n", &stack, sizeof(stack));
return 0;
}
$ ./test
ptr -> address: 0x555851314080 size: 3
stack -> address: 0x7ffde8786380 size: 3
Исправление
cumvillain,
:
#include <stdalign.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
struct aligned {
uint8_t a;
uint8_t b;
uint8_t c;
};
int
main(void)
{
struct aligned *ptr;
struct aligned alignas(128) stack;
ptr = aligned_alloc(128, sizeof(*ptr));
printf("ptr -> address: %p size: %u \n", ptr, sizeof(*ptr));
printf("stack -> address: %p size: %u \n", &stack, sizeof(stack));
return 0;
}
Исходная версия
cumvillain,
:
#include <stdalign.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
struct aligned {
uint8_t a;
uint8_t b;
uint8_t c;
};
int
main(void)
{
struct aligned *ptr;
struct aligned alignas(128) stack;
ptr = aligned_alloc(128, sizeof(*ptr));
printf("ptr -> address: %p size: %u \n", ptr, sizeof(*ptr));
printf("stack -> address: %p size: %u \n", &stack, sizeof(stack));
return 0;
}