cancel
Showing results for 
Search instead for 
Did you mean: 

STM Cube C++ Error

dhiry2k1
Associate II
Posted on January 30, 2015 at 15:51

Hi, 

    I've been trying to use the new F4 HAL libraries for a project on the STM32F427II

I realize that this will involve a lot of C to C++ integration.

My first issue is with the two enum typedefs in 

  @file    stm32f4xx_hal_def.h

typedef enum 

{

  HAL_OK       = 0x00,

  HAL_ERROR    = 0x01,

  HAL_BUSY     = 0x02,

  HAL_TIMEOUT  = 0x03

} HAL_StatusTypeDef;

&sharpendif

/** 

  * @brief  HAL Lock structures definition  

  */

typedef enum 

{

  HAL_UNLOCKED = 0x00,

  HAL_LOCKED   = 0x01  

} HAL_LockTypeDef;

These are picked up correctly in an eclipse GCC C project but not in a C++ project.

The message is 'HAL_LockTypeDef 'does not name a type. There are about 500 such messages.

Any ideas as to how to go about either getting the C typedef to be in scope of C++, or of creating something like

&sharpifdef __cplusplus

  //enum  HAL_StatusTypeDef { HAL_OK, HAL_ERROR, HAL_BUSY, HAL_TIMEOUT } ;

 enum  class HAL_StatusTypeDef { HAL_OK, HAL_ERROR, HAL_BUSY, HAL_TIMEOUT } ;

 // typedef enum   { HAL_OK, HAL_ERROR, HAL_BUSY, HAL_TIMEOUT } HAL_StatusTypeDef;

&sharpelse

typedef enum 

{

  HAL_OK       = 0x00,

  HAL_ERROR    = 0x01,

  HAL_BUSY     = 0x02,

  HAL_TIMEOUT  = 0x03

} HAL_StatusTypeDef;

&sharpendif

I am not sure how to get rid of this error. I know STMCube has support of C++ but i am unable to use. Any pointer would really be appreciated.

#stm32 #- #stm32cube #c++ #c++-hal-typedef-gcc
2 REPLIES 2
Posted on February 02, 2015 at 08:52

Hi Dheeraj,

Which STM32CubeF4 HAL drivers version are you using ?

Please download the latest

http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/firmware/stm32cubef4.zip

version, where the HAL drivers are updated to be C++ compliant.

Regards,

Heisenberg.

dhiry2k
Associate II
Posted on February 03, 2015 at 15:42

Hi Heisenberg,

I am using the latest revision of HAL layer.

Still unable to get rid of this error. I am using it on Linux GCC compiler though . My compiler flags are:

-std=gnu++0x

 -g -O0 -Wall -Wl,-Map,