Skip to content

Commit

Permalink
Packed unaligned_type
Browse files Browse the repository at this point in the history
This way, unaligned_types like etl::be_uint32_t can be used in places where POD types are expected.
  • Loading branch information
rolandreichweinbmw committed Dec 7, 2024
1 parent a88a48d commit b14e33a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions include/etl/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion include/etl/unaligned_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit b14e33a

Please sign in to comment.