Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trinamic.app unused variable #17899

Closed
thorstensd opened this issue May 6, 2020 · 6 comments
Closed

trinamic.app unused variable #17899

thorstensd opened this issue May 6, 2020 · 6 comments

Comments

@thorstensd
Copy link

thorstensd commented May 6, 2020

Hello,

I detected a problem during compile SKR 1.4 Turbo with TMC2208 and ENDER 4 Conf.

trinamic.app unused variable:

 void tmc_serial_begin() {
    struct {
      const void *ptr[TMCAxis::TOTAL];
      bool began(const TMCAxis a, const void * const p) {
        LOOP_L_N(i, a) if (p == ptr[i]) return true;
        ptr[a] = p; return false;
      };
    } sp_helper;
@ellensp
Copy link
Contributor

ellensp commented May 6, 2020

its only a warning in trinamic.cpp

Marlin/src/module/stepper/trinamic.cpp: In function 'void tmc_serial_begin()':
Marlin/src/module/stepper/trinamic.cpp:327:7: warning: unused variable 'sp_helper' [-Wunused-variable]
  327 |     } sp_helper;
      |       ^~~~~~~~~

@thisiskeithb
Copy link
Member

its only a warning in trinamic.cpp

In other words, it can be ignored 🙂

@thorstensd
Copy link
Author

thank you :-)

@thinkyhead
Copy link
Member

To suppress the warning, wrap that section with HAS_TMC_UART

#if HAS_TMC_UART
  struct {
    const void *ptr[TMCAxis::TOTAL];
    bool began(const TMCAxis a, const void * const p) {
      LOOP_L_N(i, a) if (p == ptr[i]) return true;
      ptr[a] = p; return false;
    };
  } sp_helper;
  #define HW_SERIAL_BEGIN(A) do{ if (!sp_helper.began(TMCAxis::A, &A##_HARDWARE_SERIAL)) \
                                       A##_HARDWARE_SERIAL.begin(TMC_BAUD_RATE); }while(0)
#endif

@sjasonsmith
Copy link
Contributor

I already posted a PR for it. The solution is a little different than you suggested because that would still warn if you are using software serial.

@github-actions
Copy link

github-actions bot commented Jul 7, 2020

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants