From cfca07852a8cfa5f15527b19d60093641f3063d4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 20 May 2019 21:34:23 -0500 Subject: [PATCH] Backlash linker error workaround Fix #14045 --- Marlin/src/feature/backlash.cpp | 11 ++++++++--- Marlin/src/feature/backlash.h | 14 ++++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Marlin/src/feature/backlash.cpp b/Marlin/src/feature/backlash.cpp index 67a4afb326..56701991e0 100644 --- a/Marlin/src/feature/backlash.cpp +++ b/Marlin/src/feature/backlash.cpp @@ -29,11 +29,16 @@ #include "../module/motion.h" #include "../module/planner.h" -#if ENABLED(BACKLASH_GCODE) - uint8_t Backlash::correction = (BACKLASH_CORRECTION) * 0xFF; - #ifdef BACKLASH_DISTANCE_MM +#ifdef BACKLASH_DISTANCE_MM + #if ENABLED(BACKLASH_GCODE) float Backlash::distance_mm[XYZ] = BACKLASH_DISTANCE_MM; + #else + const float Backlash::distance_mm[XYZ] = BACKLASH_DISTANCE_MM; #endif +#endif + +#if ENABLED(BACKLASH_GCODE) + uint8_t Backlash::correction = (BACKLASH_CORRECTION) * 0xFF; #ifdef BACKLASH_SMOOTHING_MM float Backlash::smoothing_mm = BACKLASH_SMOOTHING_MM; #endif diff --git a/Marlin/src/feature/backlash.h b/Marlin/src/feature/backlash.h index d1e1e63208..f2dffe1311 100644 --- a/Marlin/src/feature/backlash.h +++ b/Marlin/src/feature/backlash.h @@ -26,11 +26,16 @@ class Backlash { public: - #if ENABLED(BACKLASH_GCODE) - static uint8_t correction; - #ifdef BACKLASH_DISTANCE_MM + #ifdef BACKLASH_DISTANCE_MM + #if ENABLED(BACKLASH_GCODE) static float distance_mm[XYZ]; + #else + static const float distance_mm[XYZ]; + //static constexpr float distance_mm[XYZ] = BACKLASH_DISTANCE_MM; // compiler barks at this #endif + #endif + #if ENABLED(BACKLASH_GCODE) + static uint8_t correction; #ifdef BACKLASH_SMOOTHING_MM static float smoothing_mm; #endif @@ -38,9 +43,6 @@ public: static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; } #else static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF; - #ifdef BACKLASH_DISTANCE_MM - static constexpr float distance_mm[XYZ] = BACKLASH_DISTANCE_MM; - #endif #ifdef BACKLASH_SMOOTHING_MM static constexpr float smoothing_mm = BACKLASH_SMOOTHING_MM; #endif