added check for the u and U prefix for string literals

This commit is contained in:
hyung-hwan 2020-08-19 02:38:07 +00:00
parent 416a39868a
commit 9988b1afcd
4 changed files with 76 additions and 2 deletions

53
hawk/configure vendored
View File

@ -18517,6 +18517,59 @@ $as_echo "#define HAWK_PREFER_PREFIX_L 1" >>confdefs.h
fi fi
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for char16_t literal" >&5
$as_echo_n "checking for char16_t literal... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
const void* x = u"ab cd ef gh";
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAWK_HAVE_PREFIX_SMALL_U 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for char32_t literal" >&5
$as_echo_n "checking for char32_t literal... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
const void* x = U"ab cd ef gh";
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAWK_HAVE_PREFIX_BIG_U 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_memset" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_memset" >&5
$as_echo_n "checking for __builtin_memset... " >&6; } $as_echo_n "checking for __builtin_memset... " >&6; }

View File

@ -169,6 +169,21 @@ else
fi fi
fi fi
AC_MSG_CHECKING([for char16_t literal])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([], [const void* x = u"ab cd ef gh";])],
[AC_MSG_RESULT(yes)
AC_DEFINE([HAWK_HAVE_PREFIX_SMALL_U], [1], [char16_t literal prefix])],
[AC_MSG_RESULT(no)]
)
AC_MSG_CHECKING([for char32_t literal])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([], [const void* x = U"ab cd ef gh";])],
[AC_MSG_RESULT(yes)
AC_DEFINE([HAWK_HAVE_PREFIX_BIG_U], [1], [char32_t literal prefix])],
[AC_MSG_RESULT(no)]
)
dnl check some compiler builtins dnl check some compiler builtins
AC_MSG_CHECKING([for __builtin_memset]) AC_MSG_CHECKING([for __builtin_memset])

View File

@ -714,6 +714,12 @@
/* Unknown Endian */ /* Unknown Endian */
#undef HAWK_ENDIAN_UNKNOWN #undef HAWK_ENDIAN_UNKNOWN
/* char32_t literal prefix */
#undef HAWK_HAVE_PREFIX_BIG_U
/* char16_t literal prefix */
#undef HAWK_HAVE_PREFIX_SMALL_U
/* MB_LEN_MAX */ /* MB_LEN_MAX */
#undef HAWK_MBLEN_MAX #undef HAWK_MBLEN_MAX

View File

@ -510,7 +510,7 @@ typedef unsigned char hawk_bchu_t; /* unsigned version of hawk_bch_t f
// gcc/g++/clang/clang++: -fshort-wchar makes wchar_t to 2 bytes. // gcc/g++/clang/clang++: -fshort-wchar makes wchar_t to 2 bytes.
HAWK_STATIC_ASSERT (HAWK_WIDE_CHAR_SIZE == sizeof(hawk_uch_t)); HAWK_STATIC_ASSERT (HAWK_WIDE_CHAR_SIZE == sizeof(hawk_uch_t));
#elif defined(HAWK_WIDE_CHAR_SIZE) && (HAWK_WIDE_CHAR_SIZE >= 4) && defined(__GNUC__) && defined(__CHAR32_TYPE__) #elif defined(HAWK_WIDE_CHAR_SIZE) && (HAWK_WIDE_CHAR_SIZE >= 4) && defined(__GNUC__) && defined(__CHAR32_TYPE__) && defined(HAWK_HAVE_PREFIX_BIG_U)
typedef __CHAR32_TYPE__ hawk_uch_t; typedef __CHAR32_TYPE__ hawk_uch_t;
typedef hawk_uint32_t hawk_uchu_t; typedef hawk_uint32_t hawk_uchu_t;
# define HAWK_SIZEOF_UCH_T 4 # define HAWK_SIZEOF_UCH_T 4
@ -523,7 +523,7 @@ typedef unsigned char hawk_bchu_t; /* unsigned version of hawk_bch_t f
typedef hawk_uint32_t hawk_uchu_t; typedef hawk_uint32_t hawk_uchu_t;
# define HAWK_SIZEOF_UCH_T 4 # define HAWK_SIZEOF_UCH_T 4
#elif defined(__GNUC__) && defined(__CHAR16_TYPE__) #elif defined(__GNUC__) && defined(__CHAR16_TYPE__) && defined(HAWK_HAVE_PREFIX_SMALL_U)
typedef __CHAR16_TYPE__ hawk_uch_t; typedef __CHAR16_TYPE__ hawk_uch_t;
typedef hawk_uint16_t hawk_uchu_t; typedef hawk_uint16_t hawk_uchu_t;
# define HAWK_SIZEOF_UCH_T 2 # define HAWK_SIZEOF_UCH_T 2