From 845d1072ddff67fbec81c52b56c33eaf72e46ea1 Mon Sep 17 00:00:00 2001 From: seifemad Date: Mon, 21 Sep 2026 13:35:38 +0300 Subject: [PATCH] Fix static/extern linkage conflict for log2 timer-frequency variables RampControl.cpp declared log2_timer_freq (and its two derived values) static, while RampGenerator.h declares them extern for use from RampGenerator.cpp, a separate translation unit. A static redeclaration cannot follow a non-static one in the same TU, so this fails to build for any platform whose TICKS_PER_S isn't exactly 16000000 or 21000000 (the two values RampCalculator.h has precomputed fast-path constants for) - e.g. AVR boards not running at 16/21 MHz. --- CHANGELOG.md | 3 +++ src/fas_ramp/RampControl.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff2863af..cfa12536 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +Unreleased: +- fix: RampControl.cpp declared the log2 timer-frequency variables `static`, conflicting with their `extern` declaration in RampGenerator.h. That combination is ill-formed C++ (a static redeclaration cannot follow a non-static/extern one in the same translation unit) and breaks the build for any platform whose TICKS_PER_S isn't exactly 16000000 or 21000000 - e.g. an AVR board not running at 16/21 MHz - the moment SUPPORT_LOG2_TIMER_FREQ_VARIABLES is exercised + 1.3.3: - moveTimed(0, duration): pause uses last direction XOR prepare_revert (default false does not toggle DIR; true pauses in the opposite direction) diff --git a/src/fas_ramp/RampControl.cpp b/src/fas_ramp/RampControl.cpp index 800c4fb9..47afc952 100644 --- a/src/fas_ramp/RampControl.cpp +++ b/src/fas_ramp/RampControl.cpp @@ -7,9 +7,12 @@ #include "fas_arch/common.h" #ifdef SUPPORT_LOG2_TIMER_FREQ_VARIABLES -static log2_value_t log2_timer_freq; -static log2_value_t log2_timer_freq_div_sqrt_of_2; -static log2_value_t log2_timer_freq_square_div_2; +// Definitions for the `extern` declarations in RampGenerator.h. Must have +// external linkage (no `static`): RampGenerator.cpp, a separate translation +// unit, also uses these via the LOG2_TICKS_PER_S* macros in RampCalculator.h. +log2_value_t log2_timer_freq; +log2_value_t log2_timer_freq_div_sqrt_of_2; +log2_value_t log2_timer_freq_square_div_2; #endif void ramp_rw_s::init() {