Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/runtime/include/iec_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <array>
#include <cstdint>
#include <initializer_list>
#ifndef __AVR__
#include <stdexcept>
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/runtime/include/iec_enum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#pragma once

#include <cstdint>
#ifndef __AVR__
#include <ostream>
#endif
#include <type_traits>
#include "iec_var.hpp"

Expand Down Expand Up @@ -213,12 +215,14 @@ class IEC_ENUM_Var {
template<typename EnumType>
using IEC_ENUM = IEC_ENUM_Var<EnumType>;

#ifndef __AVR__
// Stream output for IEC_ENUM_Var — outputs underlying integer value
template<typename EnumType>
inline std::ostream& operator<<(std::ostream& os, const IEC_ENUM_Var<EnumType>& v) {
return os << static_cast<typename std::underlying_type<EnumType>::type>(
static_cast<EnumType>(v));
}
#endif

/*
* Example generated enumeration:
Expand Down
8 changes: 5 additions & 3 deletions src/runtime/include/iec_located.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ struct LocatedVar {
}
};

// Verify expected layout
static_assert(sizeof(LocatedVar) == 16, "LocatedVar should be 16 bytes");
static_assert(alignof(LocatedVar) == 8, "LocatedVar should be 8-byte aligned");
// Verify expected layout (size varies by platform: 16 bytes on 64-bit, 8 on 32-bit, 6 on AVR)
#if INTPTR_MAX == INT64_MAX
static_assert(sizeof(LocatedVar) == 16, "LocatedVar should be 16 bytes on 64-bit");
static_assert(alignof(LocatedVar) == 8, "LocatedVar should be 8-byte aligned on 64-bit");
#endif

// =============================================================================
// Helper Functions for Address Parsing
Expand Down
8 changes: 4 additions & 4 deletions src/runtime/include/iec_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,11 @@ template<typename T> struct is_iec_array : std::false_type {};
template<typename T, typename B>
struct is_iec_array<IEC_ARRAY_1D<T, B>> : std::true_type {};

template<typename T, typename B1, typename B2>
struct is_iec_array<IEC_ARRAY_2D<T, B1, B2>> : std::true_type {};
template<typename T, typename Bnd1, typename Bnd2>
struct is_iec_array<IEC_ARRAY_2D<T, Bnd1, Bnd2>> : std::true_type {};

template<typename T, typename B1, typename B2, typename B3>
struct is_iec_array<IEC_ARRAY_3D<T, B1, B2, B3>> : std::true_type {};
template<typename T, typename Bnd1, typename Bnd2, typename Bnd3>
struct is_iec_array<IEC_ARRAY_3D<T, Bnd1, Bnd2, Bnd3>> : std::true_type {};

template<typename T>
inline constexpr bool is_iec_array_v = is_iec_array<T>::value;
Expand Down
Loading