'Go To Declaration' won't work from a definition

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • 'Go To Declaration' won't work from a definition

      New

      Nordic are very fond of this kind of thing:

      C Source Code

      1. /** @brief Macro for forwarding the new implementation. */
      2. #define nrf_drv_gpiote_init nrfx_gpiote_init
      3. /** @brief Macro for forwarding the new implementation. */
      4. #define nrf_drv_gpiote_is_init nrfx_gpiote_is_init
      5. /** @brief Macro for forwarding the new implementation. */
      6. #define nrf_drv_gpiote_uninit nrfx_gpiote_uninit
      7. /** @brief Macro for forwarding the new implementation. */
      8. #define nrf_drv_gpiote_out_init nrfx_gpiote_out_init
      9. /** @brief Macro for forwarding the new implementation. */
      10. #define nrf_drv_gpiote_out_uninit nrfx_gpiote_out_uninit
      11. /** @brief Macro for forwarding the new implementation. */
      12. #define nrf_drv_gpiote_out_set nrfx_gpiote_out_set
      Display All
      ie, renaming functions via #defines.

      So, for example, in my code I might call nrf_drv_gpiote_init:

      C Source Code

      1. err_code = nrf_drv_gpiote_init();
      2. APP_ERROR_CHECK(err_code);

      If I do either 'Go To Definition' or 'Go To Declaration' on that call, they both end up at the #define



      C Source Code

      1. /** @brief Macro for forwarding the new implementation. */
      2. #define nrf_drv_gpiote_in_init nrfx_gpiote_in_init
      Which is all fine and correct.


      But, if I select nrfx_gpiote_in_init on that #define line, then 'Go To Declaration' will go to the definition - not the declaration:

      C Source Code

      1. nrfx_err_t nrfx_gpiote_in_init(nrfx_gpiote_pin_t pin,
      2. nrfx_gpiote_in_config_t const * p_config,
      3. nrfx_gpiote_evt_handler_t evt_handler)
      4. {
      5. NRFX_ASSERT(pin < NUMBER_OF_PINS);
      6. nrfx_err_t err_code = NRFX_SUCCESS;
      7. :
      8. :

      This is WRONG!


      And 'Go To Declaration' at that point does nothing.

      Why is this important?

      Because, as is common practice, the documentation is with the declaration - not the definition:

      C Source Code

      1. /**
      2. * @brief Function for initializing a GPIOTE input pin.
      3. * @details The input pin can act in two ways:
      4. * - lower accuracy but low power (high frequency clock not needed)
      5. * - higher accuracy (high frequency clock required)
      6. *
      7. * The initial configuration specifies which mode is used.
      8. * If high-accuracy mode is used, the driver attempts to allocate one
      9. * of the available GPIOTE channels. If no channel is
      10. * available, an error is returned.
      11. * In low accuracy mode SENSE feature is used. In this case only one active pin
      12. * can be detected at a time. It can be worked around by setting all of the used
      13. * low accuracy pins to toggle mode.
      14. * For more information about SENSE functionality, refer to Product Specification.
      15. *
      16. * @param[in] pin Pin.
      17. * @param[in] p_config Initial configuration.
      18. * @param[in] evt_handler User function to be called when the configured transition occurs.
      19. *
      20. * @retval NRFX_SUCCESS If initialization was successful.
      21. * @retval NRFX_ERROR_INVALID_STATE If the driver is not initialized or the pin is already used.
      22. * @retval NRFX_ERROR_NO_MEM If no GPIOTE channel is available.
      23. */
      24. nrfx_err_t nrfx_gpiote_in_init(nrfx_gpiote_pin_t pin,
      25. nrfx_gpiote_in_config_t const * p_config,
      26. nrfx_gpiote_evt_handler_t evt_handler);
      Display All