[En-Nut-Discussion] Next Nut/OS 5 release candidate

Harald Kipp harald.kipp at egnite.de
Thu Oct 11 17:39:09 CEST 2012


Hi Uwe,

On 11.10.2012 16:25, Uwe Bonnes wrote:
>>>>>> "Harald" == Harald Kipp <harald.kipp at egnite.de> writes:
> 
>     Harald> int FooBarApi(void) { 
>     Harald> #ifdef GPIO_CFG_INIT_HIGH /* Normal code. */ 
>     Harald> ...  return 0; 
>     Harald> #else /* Not supported, return an error. */
>     Harald> return -1;
>     Harald>  #endif
>     Harald>  }
> 
> But with  nut/include/dev/gpio.h containing
> 
> #define  GPIO_CFG_UNIMPLEMENTED 0
> 
> #if !defined(GPIO_CFG_INIT_HIGH)
> #define GPIO_CFG_INIT_HIGH GPIO_CFG_UNIMPLEMENTED
> #endif
> 
> #if !defined(GPIO_CFG_INIT_LOW)
> #define GPIO_CFG_INIT_LOW GPIO_CFG_UNIMPLEMENTED
> #endif
> , your user code above _can_ do
> #if (GPIO_CFG_INIT_LOW == GPIO_CFG_UNIMPLEMENTED)
> ==warn user==
> #endif
> if the requested feature is essential, but compile will _not_ break if user
> code handles the feature as a welcome feature, not a must..

Yes, this looks like a good solution to me too.

Regards,

Harald





More information about the En-Nut-Discussion mailing list