opendbc icon indicating copy to clipboard operation
opendbc copied to clipboard

No-op changes to make Panda happy

Open aubsw opened this issue 8 months ago • 1 comments

No-op change for https://github.com/commaai/panda/issues/2171

  • Moves some functions and declarations around so that they can be correctly included in Panda headers.

Details

In panda, we currently need some defintions from safety.h. But we can't include safety.h directly because it contains function implementatinos (we eventually should link the implementations at compile time).

So in this PR, we're just safely moving code that will allow us to include headers from opendbc without compiler errors.

  • Panda needs access to SAFETY_ALLOUTPUT. But we can't directly include safety.h anywhere in panda because safety.h contains implementations (can't link multiple objects files that contain definitions for the same functions).
    • Hence, we move the definition of SAFETY_ALLOUTPUT to safety_declarations.h, which we can then include in panda source.
  • Move forward declarations of generic_rx_checks and stock_ecu_check from safety_declarations.h to safety.h (since can't include forward-declared static functions without their corresponding implementation)
  • make get_ts_elapsed static inline! This way we can safely include utils.h without compiler errors for multiple definitions.

Further discussion: https://github.com/commaai/panda/issues/2171#issuecomment-2784918381

aubsw avatar Apr 03 '25 19:04 aubsw

LGTM, @sshane any comments?

robbederks avatar Apr 08 '25 13:04 robbederks