1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

Tests: Cover CheckTypeSize with uint8_t and std::uint8_t

This commit is contained in:
Brad King
2020-07-20 15:53:12 -04:00
parent 371072e9e1
commit 7f786c6a40
3 changed files with 38 additions and 0 deletions

View File

@@ -21,6 +21,8 @@ check_type_size("((struct somestruct*)0)->somechar" SIZEOF_STRUCTMEMBER_CHAR)
# Check CXX types
check_type_size(bool SIZEOF_BOOL LANGUAGE CXX)
check_type_size(uint8_t SIZEOF_UINT8_T LANGUAGE CXX)
check_type_size(std::uint8_t SIZEOF_STD_UINT8_T LANGUAGE CXX)
set(CMAKE_EXTRA_INCLUDE_FILES someclass.hxx)
check_type_size("((ns::someclass*)0)->someint" SIZEOF_NS_CLASSMEMBER_INT LANGUAGE CXX)

View File

@@ -11,6 +11,12 @@
#ifdef HAVE_STDDEF_H
# include <stddef.h>
#endif
#ifdef HAVE_CSTDINT
# include <cstdint>
#endif
#ifdef HAVE_CSTDDEF
# include <cstddef>
#endif
#include <stdio.h>
@@ -122,6 +128,26 @@ int main()
NODEF(SIZEOF_SSIZE_T);
#endif
/* uint8_t */
#if defined(SIZEOF_UINT8_T)
CHECK(uint8_t, SIZEOF_UINT8_T);
# if !defined(HAVE_SIZEOF_UINT8_T)
NODEF(HAVE_SIZEOF_UINT8_T);
# endif
#elif defined(HAVE_SIZEOF_UINT8_T)
NODEF(SIZEOF_UINT8_T);
#endif
/* std::uint8_t */
#if defined(SIZEOF_STD_UINT8_T)
CHECK(std::uint8_t, SIZEOF_STD_UINT8_T);
# if !defined(HAVE_SIZEOF_STD_UINT8_T)
NODEF(HAVE_SIZEOF_STD_UINT8_T);
# endif
#elif defined(HAVE_SIZEOF_STD_UINT8_T)
NODEF(SIZEOF_STD_UINT8_T);
#endif
/* ns::someclass::someint */
#if defined(SIZEOF_NS_CLASSMEMBER_INT)
CHECK(y.someint, SIZEOF_NS_CLASSMEMBER_INT);

View File

@@ -1,11 +1,21 @@
#cmakedefine HAVE_SYS_TYPES_H
#cmakedefine HAVE_STDINT_H
#cmakedefine HAVE_STDDEF_H
#cmakedefine HAVE_CSTDINT
#cmakedefine HAVE_CSTDDEF
/* bool */
#cmakedefine HAVE_SIZEOF_BOOL
@SIZEOF_BOOL_CODE@
/* uint8_t */
#cmakedefine HAVE_SIZEOF_UINT8_T
@SIZEOF_UINT8_T_CODE@
/* std::uint8_t */
#cmakedefine HAVE_SIZEOF_STD_UINT8_T
@SIZEOF_STD_UINT8_T_CODE@
/* struct ns::somestruct::someint */
#cmakedefine HAVE_SIZEOF_NS_STRUCTMEMBER_INT
@SIZEOF_NS_STRUCTMEMBER_INT_CODE@