From 6618346148aec206393880c269bd0e464d2d29f5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 18 Mar 2017 10:18:40 -0500 Subject: [PATCH] Patches to work around "register spill" compiler bug --- Marlin/temperature.cpp | 13 +++++++++++++ Marlin/temperature.h | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index af76edb0f..883133806 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -24,6 +24,8 @@ * temperature.cpp - temperature control */ + + #include "Marlin.h" #include "ultralcd.h" #include "temperature.h" @@ -666,6 +668,17 @@ float Temperature::get_pid_output(int e) { * - Apply filament width to the extrusion rate (may move) * - Update the heated bed PID output value */ + +/** + * The following line SOMETIMES results in the dreaded "unable to find a register to spill in class 'POINTER_REGS'" + * compile error. + * thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS); + * + * This is due to a bug in the C++ compiler used by the Arduino IDE from 1.6.10 to at least 1.8.1. + * + * The work around is to add the compiler flag "__attribute__((__optimize__("O2")))" to the declaration for manage_heater() + */ +//void Temperature::manage_heater() __attribute__((__optimize__("O2"))); void Temperature::manage_heater() { if (!temp_meas_ready) return; diff --git a/Marlin/temperature.h b/Marlin/temperature.h index e59214844..d6451554f 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -241,7 +241,8 @@ class Temperature { /** * Call periodically to manage heaters */ - static void manage_heater(); + //static void manage_heater(); // changed to address compiler error + static void manage_heater() __attribute__((__optimize__("O2"))); /** * Preheating hotends