Directory: Avoid use of unnamed struct in union

Anonymous structs have a limitation on GCC when involving non-trivial
default constructors, as it's a compiler extension and not actually
standard C++ to use anonymous structs. We can give the struct a concrete
name, which fixes this issue.
This commit is contained in:
Lioncash
2019-09-02 00:47:07 -04:00
committed by Phillip Stephens
parent 42c4ae8daa
commit b7a5e3b36c
4 changed files with 35 additions and 31 deletions

View File

@@ -8,14 +8,15 @@ namespace kabufuda {
class Directory {
friend class Card;
#pragma pack(push, 4)
struct Data {
std::array<File, MaxFiles> m_files;
std::array<uint8_t, 0x3a> padding;
uint16_t m_updateCounter;
uint16_t m_checksum;
uint16_t m_checksumInv;
};
union {
struct {
std::array<File, MaxFiles> m_files;
std::array<uint8_t, 0x3a> padding;
uint16_t m_updateCounter;
uint16_t m_checksum;
uint16_t m_checksumInv;
};
Data data;
std::array<uint8_t, BlockSize> raw;
};
#pragma pack(pop)

View File

@@ -42,6 +42,8 @@ union SRAMFlags {
};
union SRAM {
using FlashID = std::array<std::array<uint8_t, 12>, 2>;
std::array<uint8_t, 64> p_SRAM;
struct // Stored configuration value from the system SRAM area
{
@@ -56,7 +58,6 @@ union SRAM {
SRAMFlags flags; // Device and operations flag
// Stored configuration value from the extended SRAM area
using FlashID = std::array<std::array<uint8_t, 12>, 2>;
FlashID flash_id; // flash_id[2][12] 96bit memorycard unlock flash ID
uint32_t wirelessKbd_id; // Device ID of last connected wireless keyboard
std::array<uint16_t, 4> wirelessPad_id; // 16-bit device ID of last connected pad.