Feature or enhancement
Proposal:
The struct module uses pre-C11 hacks to determine alignment for types:
| /* Define various structs to figure out the alignments of types */ |
| |
| |
| typedefstruct { charc; shortx; } st_short; |
| typedefstruct { charc; intx; } st_int; |
| typedefstruct { charc; longx; } st_long; |
| typedefstruct { charc; floatx; } st_float; |
| typedefstruct { charc; doublex; } st_double; |
| #ifdefPy_HAVE_C_COMPLEX |
| typedefstruct { charc; floatcomplexx; } st_float_complex; |
| typedefstruct { charc; doublecomplexx; } st_double_complex; |
| #endif |
| typedefstruct { charc; void*x; } st_void_p; |
| typedefstruct { charc; size_tx; } st_size_t; |
| typedefstruct { charc; _Boolx; } st_bool; |
| |
| #defineSHORT_ALIGN (sizeof(st_short) - sizeof(short)) |
| #defineINT_ALIGN (sizeof(st_int) - sizeof(int)) |
| #defineLONG_ALIGN (sizeof(st_long) - sizeof(long)) |
| #defineFLOAT_ALIGN (sizeof(st_float) - sizeof(float)) |
| #defineDOUBLE_ALIGN (sizeof(st_double) - sizeof(double)) |
| #ifdefPy_HAVE_C_COMPLEX |
| # defineFLOAT_COMPLEX_ALIGN (sizeof(st_float_complex) - sizeof(float complex)) |
| # defineDOUBLE_COMPLEX_ALIGN (sizeof(st_double_complex) - sizeof(double complex)) |
| #endif |
| #defineVOID_P_ALIGN (sizeof(st_void_p) - sizeof(void *)) |
| #defineSIZE_T_ALIGN (sizeof(st_size_t) - sizeof(size_t)) |
| #defineBOOL_ALIGN (sizeof(st_bool) - sizeof(_Bool)) |
Now we can use _Alignof operator, as C11-compatible compiler is a build requireent.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
Feature or enhancement
Proposal:
The struct module uses pre-C11 hacks to determine alignment for types:
cpython/Modules/_struct.c
Lines 79 to 106 in 5808889
Now we can use
_Alignofoperator, as C11-compatible compiler is a build requireent.Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs