Page 1 of 1

halconf and preprocessor switches

Posted: Thu Nov 18, 2021 3:06 pm
by Guillaume227
Seeing how halconf.h is laid out with preprocessor switches like:

Code: Select all

#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__)
#define HAL_USE_SIO   FALSE
#endif

I expected to be able to set HAL_USE_SIO in the Makefile (e.g. USE_OPT+= -DHAL_USE_SIO=TRUE) as an alternative to editing the halconf.h file.
I ran into undefined errors which I tracked down to that kind of statement in driver.mk:

Code: Select all

ifneq ($(findstring HAL_USE_SIO TRUE,$(HALCONF)),)


So it seems the only way to activate a HAL feature is to actually have a different copy of halconf where the feature is set to TRUE?
Is it just me thinking that's misleading? Am I missing a way to turn a hal feature on 'programmatically'?

Re: halconf and preprocessor switches

Posted: Thu Nov 18, 2021 3:08 pm
by Giovanni
Hi,

You need to disable the "smart build" option in the makefile then you can add -D switches to override configuration files.

Giovanni

Re: halconf and preprocessor switches

Posted: Thu Nov 18, 2021 3:27 pm
by Guillaume227
Sounds good - trading some compilation time in that case is totally fine. Thank you Giovanni.