Cart_Reader.ino: Move definitions after all forward declarations

It seems the Arduino IDE picks the position of the first definition to
insert all auto-generated forward declarations. This fails to compile if
any of these generated forward declarations references a type included
later.
So, reorder the code a bit so the first definition happens strictly after
the last inclusion.
This commit is contained in:
Vincent Pelletier 2022-10-31 08:03:31 +00:00
parent ab9e36e12e
commit 78c05c826c

View File

@ -224,22 +224,6 @@ boolean dont_log = false;
template<class T> int EEPROM_writeAnything(int ee, const T& value);
template<class T> int EEPROM_readAnything(int ee, T& value);
template<class T> int EEPROM_writeAnything(int ee, const T& value) {
const byte* p = (const byte*)(const void*)&value;
unsigned int i;
for (i = 0; i < sizeof(value); i++)
EEPROM.write(ee++, *p++);
return i;
}
template<class T> int EEPROM_readAnything(int ee, T& value) {
byte* p = (byte*)(void*)&value;
unsigned int i;
for (i = 0; i < sizeof(value); i++)
*p++ = EEPROM.read(ee++);
return i;
}
// Graphic SPI LCD
#ifdef enable_LCD
#include <U8g2lib.h>
@ -302,6 +286,26 @@ void _print_FatalError(void) __attribute__((noreturn));
void print_FatalError(const __FlashStringHelper* errorMessage) __attribute__((noreturn));
void print_FatalError(byte errorMessage) __attribute__((noreturn));
/******************************************
End of inclusions and forward declarations
*****************************************/
template<class T> int EEPROM_writeAnything(int ee, const T& value) {
const byte* p = (const byte*)(const void*)&value;
unsigned int i;
for (i = 0; i < sizeof(value); i++)
EEPROM.write(ee++, *p++);
return i;
}
template<class T> int EEPROM_readAnything(int ee, T& value) {
byte* p = (byte*)(void*)&value;
unsigned int i;
for (i = 0; i < sizeof(value); i++)
*p++ = EEPROM.read(ee++);
return i;
}
/******************************************
Common Strings
*****************************************/