diff --git a/include/etl/platform.h b/include/etl/platform.h index e66a0e08d..f8d8752de 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -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" diff --git a/include/etl/unaligned_type.h b/include/etl/unaligned_type.h index 9b4ae6629..77e38ce12 100644 --- a/include/etl/unaligned_type.h +++ b/include/etl/unaligned_type.h @@ -227,7 +227,7 @@ namespace etl ///\tparam Endian The endianness of the arithmetic type. //************************************************************************* template - class unaligned_type : public private_unaligned_type::unaligned_type_common + class ETL_PACKED unaligned_type : public private_unaligned_type::unaligned_type_common { public: