Packed unaligned_type (#989)

This way, unaligned_types like etl::be_uint32_t can be used in places where POD types are expected.
This commit is contained in:
rolandreichweinbmw 2024-12-14 22:36:15 +01:00 committed by GitHub
parent 99d7537506
commit 84eea5bb1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -454,6 +454,14 @@ SOFTWARE.
#define ETL_HAS_INITIALIZER_LIST 0
#endif
//*************************************
// Determine if the ETL should use __attribute__((packed).
#if defined(ETL_COMPILER_CLANG) || defined(ETL_COMPILER_GCC) || defined(ETL_COMPILER_INTEL)
#define ETL_PACKED __attribute__((packed))
#else
#define ETL_PACKED
#endif
//*************************************
// Check for availability of certain builtins
#include "profiles/determine_builtin_support.h"

View File

@ -227,7 +227,7 @@ namespace etl
///\tparam Endian The endianness of the arithmetic type.
//*************************************************************************
template <typename T, int Endian_>
class unaligned_type : public private_unaligned_type::unaligned_type_common<sizeof(T)>
class ETL_PACKED unaligned_type : public private_unaligned_type::unaligned_type_common<sizeof(T)>
{
public: