| 1 |
project('alignment', 'c', 'cpp') |
| 2 |
|
| 3 |
compilers = [meson.get_compiler('c'), meson.get_compiler('cpp')] |
| 4 |
|
| 5 |
foreach cc : compilers |
| 6 |
# These tests should return the same value on all |
| 7 |
# platforms. If (and when) they don't, fix 'em up. |
| 8 |
if cc.alignment('char') != 1 |
| 9 |
error('Alignment of char misdetected.') |
| 10 |
endif |
| 11 |
|
| 12 |
ptr_size = cc.sizeof('void*') |
| 13 |
dbl_alignment = cc.alignment('double') |
| 14 |
|
| 15 |
# These tests are not thorough. Doing this properly |
| 16 |
# would take a lot of work because it is strongly |
| 17 |
# platform and compiler dependent. So just check |
| 18 |
# that they produce something fairly sane. |
| 19 |
|
| 20 |
if ptr_size == 8 or ptr_size == 4 |
| 21 |
message('Size of ptr ok.') |
| 22 |
else |
| 23 |
error('Size of ptr misdetected.') |
| 24 |
endif |
| 25 |
|
| 26 |
if dbl_alignment == 8 or dbl_alignment == 4 |
| 27 |
message('Alignment of double ok.') |
| 28 |
else |
| 29 |
error('Alignment of double misdetected.') |
| 30 |
endif |
| 31 |
endforeach |