Given this Kconfig:
config MY_STR
string "A string"
The directive #if defined(CONFIG_MY_STR)
will eval to true for the default empty string.
How to check if CONFIG_MY_STR is an empty string at compile time? Is it a better practice to use a second boolean value (e.g. CONFIG_USE_MY_STR) like the following?
config MY_STR
string "A string"
depends on USE_MY_STR
config USE_MY_STR
bool "Enable MY_STR"
Since string symbols implicitly default to the empty string the BUILD_ASSERT() can be used to perform compile time check:
And pass it during the build like