Skip to content

Commit

Permalink
Fix check for long double being the same as double
Browse files Browse the repository at this point in the history
meson's compiler.sizeof function requires 'stdio.h' for some
reason. Work around this by creating a test which returns true when
the two types have the same size.

Signed-off-by: Keith Packard <[email protected]>
  • Loading branch information
keith-packard committed May 6, 2020
1 parent c0073d0 commit da85a51
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,13 @@ long double test()
'''
have_long_double = meson.get_compiler('c').compiles(long_double_code, name : 'long double check')

long_double_size_code = '''
#include <float.h>
char size_test[sizeof(double) == sizeof(long double) ? 1 : -1];
'''

if have_long_double
long_double_size = meson.get_compiler('c').sizeof('long double')
double_size = meson.get_compiler('c').sizeof('double')
long_double_equals_double = long_double_size > 0 and long_double_size == double_size
long_double_equals_double = meson.get_compiler('c').compiles(long_double_size_code, name : 'long double same as double')
endif

if enable_multilib
Expand Down

0 comments on commit da85a51

Please sign in to comment.