Skip to content

Fix Smith Predictor compilation guards#1094

Merged
nerdCopter merged 1 commit intomasterfrom
BUGFIX_Smith_gating
Oct 21, 2025
Merged

Fix Smith Predictor compilation guards#1094
nerdCopter merged 1 commit intomasterfrom
BUGFIX_Smith_gating

Conversation

@nerdCopter
Copy link
Member

TL;DR: Move applySmithPredictor function declaration inside USE_SMITH_PREDICTOR guard
and guard the function call in gyro_filter_impl.h to prevent compilation errors
when the Smith Predictor feature is disabled.


Pull Request Description

Title: Fix Smith Predictor compilation guards

Description:

Problem

The Smith Predictor feature had incomplete preprocessor guards, causing compilation errors when USE_SMITH_PREDICTOR is undefined. Two unguarded locations were found:

  1. Function declaration: The applySmithPredictor() function declaration in src/main/sensors/gyro.h was not protected with #ifdef USE_SMITH_PREDICTOR
  2. Function call: The call to applySmithPredictor() in src/main/sensors/gyro_filter_impl.h was not guarded

Root Cause

  • smithPredictor_t typedef: ✅ Guarded with #ifdef USE_SMITH_PREDICTOR
  • applySmithPredictor declaration: ❌ NOT guarded (was outside the #ifdef)
  • applySmithPredictor call: ❌ NOT guarded

Solution

  1. Fixed function declaration: Moved applySmithPredictor declaration inside the existing #ifdef USE_SMITH_PREDICTOR block in gyro.h
  2. Fixed function call: Guarded the applySmithPredictor call in gyro_filter_impl.h with #ifdef USE_SMITH_PREDICTOR

Files Changed

  • src/main/sensors/gyro.h: Moved function declaration into proper guard
  • src/main/sensors/gyro_filter_impl.h: Guarded function call

Impact

  • ✅ Fixes compilation errors in unit tests and builds where USE_SMITH_PREDICTOR is undefined
  • ✅ Maintains compatibility with existing firmware builds where the feature is enabled
  • ✅ No functional changes to the Smith Predictor feature itself

Testing

  • Verified header compiles with USE_SMITH_PREDICTOR defined (types/functions available)
  • Verified header compiles without USE_SMITH_PREDICTOR defined (no compilation errors)
  • Verified full firmware builds succeed in both configurations
  • Unit tests now pass the compilation phase (linking issues are separate)
  • Verified flashing both versions to HELIOSPRING flight controller:
    • With USE_SMITH_PREDICTOR: CLI shows Smith Predictor settings available
    • Without USE_SMITH_PREDICTOR: CLI shows no Smith Predictor settings (feature properly disabled)
  • Not flight tested

Resolves: Unit test compilation blocker documented in tmp/20251021_FIRMWARE_BUG_SMITH_PREDICTOR_DECLARATION.md

Move applySmithPredictor function declaration inside USE_SMITH_PREDICTOR guard
and guard the function call in gyro_filter_impl.h to prevent compilation errors
when the Smith Predictor feature is disabled.
@nerdCopter nerdCopter requested a review from Copilot October 21, 2025 16:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes compilation errors that occur when the Smith Predictor feature is disabled by adding missing preprocessor guards. The function declaration and call site were not properly protected, causing build failures in configurations without USE_SMITH_PREDICTOR defined.

Key changes:

  • Moved applySmithPredictor() function declaration inside the #ifdef USE_SMITH_PREDICTOR guard
  • Added #ifdef USE_SMITH_PREDICTOR guard around the function call in the gyro filter implementation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/main/sensors/gyro.h Relocated function declaration inside existing preprocessor guard for Smith Predictor feature
src/main/sensors/gyro_filter_impl.h Added preprocessor guard around Smith Predictor function call

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@nerdCopter nerdCopter merged commit 62b68a8 into master Oct 21, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants