diff options
author | Brad King <brad.king@kitware.com> | 2020-07-20 19:53:12 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-07-22 12:25:09 (GMT) |
commit | 7f786c6a40b8a6a422cb4fce40f7aa17a037e1c1 (patch) | |
tree | 411c23d8f992dec9e02dd80f86421350ea3cff2b /Tests | |
parent | 371072e9e1677e883d3feed167b53e075fb129b3 (diff) | |
download | CMake-7f786c6a40b8a6a422cb4fce40f7aa17a037e1c1.zip CMake-7f786c6a40b8a6a422cb4fce40f7aa17a037e1c1.tar.gz CMake-7f786c6a40b8a6a422cb4fce40f7aa17a037e1c1.tar.bz2 |
Tests: Cover CheckTypeSize with uint8_t and std::uint8_t
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/Module/CheckTypeSize/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/Module/CheckTypeSize/CheckTypeSize.cxx | 26 | ||||
-rw-r--r-- | Tests/Module/CheckTypeSize/config.hxx.in | 10 |
3 files changed, 38 insertions, 0 deletions
diff --git a/Tests/Module/CheckTypeSize/CMakeLists.txt b/Tests/Module/CheckTypeSize/CMakeLists.txt index 16989fe2..102cf0c 100644 --- a/Tests/Module/CheckTypeSize/CMakeLists.txt +++ b/Tests/Module/CheckTypeSize/CMakeLists.txt @@ -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) diff --git a/Tests/Module/CheckTypeSize/CheckTypeSize.cxx b/Tests/Module/CheckTypeSize/CheckTypeSize.cxx index 15dc890..45cd393 100644 --- a/Tests/Module/CheckTypeSize/CheckTypeSize.cxx +++ b/Tests/Module/CheckTypeSize/CheckTypeSize.cxx @@ -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); diff --git a/Tests/Module/CheckTypeSize/config.hxx.in b/Tests/Module/CheckTypeSize/config.hxx.in index 8c66ade..9a80689 100644 --- a/Tests/Module/CheckTypeSize/config.hxx.in +++ b/Tests/Module/CheckTypeSize/config.hxx.in @@ -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@ |