Clemens Chu

STM32L0 HAL Driver Bug (v1.8.1 stm32l0xx_hal_tsc.h)

Discussion created by Clemens Chu on Oct 23, 2017

Hi all,

 

I had a hard time finding a missing closing curly bracket.

My code is written in C++ so usually the libraries should be included using the existing:

#ifdef __cplusplus

extern "C" {

#endif

// C code

 

#ifdef __cplusplus

}

#endif

Now let's have a look at the end of the file stm32l0xx_hal_tsc.h (line: 651):

 

#ifdef __cplusplus
}
#endif

#endif /*__STM32L0xx_TSC_H */
#endif /* #if !defined (STM32L011xx) && !defined (STM32L021xx) && !defined (STM32L031xx) && !defined (STM32L041xx) && !defined (STM32L051xx) && !defined (STM32L061xx) && !defined (STM32L071xx) && !defined (STM32L081xx) */

The closing bracket exists only if the expression (see below) is true:

#if !defined (STM32L011xx) && !defined (STM32L021xx) && !defined (STM32L031xx) && !defined (STM32L041xx) && !defined (STM32L051xx) && !defined (STM32L061xx) && !defined (STM32L071xx) && !defined (STM32L081xx)

 

 

To fix this I reordered the last lines:

#endif /* #if !defined (STM32L011xx) && !defined (STM32L021xx) && !defined (STM32L031xx) && !defined (STM32L041xx) && !defined (STM32L051xx) && !defined (STM32L061xx) && !defined (STM32L071xx) && !defined (STM32L081xx) */

#ifdef __cplusplus

}
#endif

#endif /*__STM32L0xx_TSC_H */

 

 

 

Cheers

Outcomes