Kconfig defines not showing in ifdef, ifdef greyed out

Hi All,

I was looking at the RNG example (nrf/samples/crypto/rng) when I've encountered some issues with ifdefs.
The .conf file has the default settings:

# The Zephyr CMSIS emulation assumes that ticks are ms, currently
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000

CONFIG_MAIN_STACK_SIZE=4096
CONFIG_HEAP_MEM_POOL_SIZE=4096

# Enable loging using RTT and UART
CONFIG_CONSOLE=y
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=y
CONFIG_LOG_BUFFER_SIZE=15360
CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=15360

# Enable nordic security backend and PSA APIs
CONFIG_NRF_SECURITY=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y

CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=8192
CONFIG_PSA_CRYPTO_DRIVER_OBERON=n
CONFIG_PSA_CRYPTO_DRIVER_CC3XX=y


The example is building and running fine.
But when I click "Go to definition" on "psa_generate_random()" which opens "psa_crypto.c"
Everything is greyed out after #if defined(MBEDTLS_PSA_CRYPTO_C)


How can I get visual studio code to show me that this is actually defined.
I know it is because everything is building and running as expected.

OS: Win11
IDE: Visual Studio Code
SDK: NRF Connect 2.2.0
HW: nrf52840dk_nrf52840

Thanks.

With kind regards,
Martijn

Parents Reply Children
  • Sorry for the late reply. I was out of office last week due to public holidays here in Norway. 

    Ifdefs in itself works, the issue is for the IDE to understand what configurations that are currently selected. Especially if you have multiple projects open at once. I will forward your ticket to our nRF Connect for VS Code team, but I think it is a mix of our tool, and the external tools that they use that causes the highlighting to not always be correct. If you are in doubt whether a config is set or not, you should check the build folder:

    build\zephyr\include\generated\autoconf.h, to see what your build actually uses. Remember that it is not that easy for the IDE to actually predict what all the definitions will be without actually compiling the application, which it obviously doesn't do all the time when you are editing.

    So as I mentioned in my initial reply, the highlighting is guiding, and nice to have, but you should be aware that it is not always correct (that goes both ways). 

    Best regards,

    Edvin

Related