cancel
Showing results for 
Search instead for 
Did you mean: 

including stm32f1xx_hal.h to static c++ library doesn't work

Ubus99
Associate III

Hi, I'm trying to import stm32f1xx_hal.h to my static c++ library to have access to the standard types and functions.

It used to work when the project was still c, but after migration it doesn't recognize the types any more, even though it doesn't fail to include.

I have include guards and external c in place:

#ifndef LTC6803LIBF103_HPP
#define LTC6803LIBF103_HPP
 
#ifdef __cplusplus
extern "C" {
#endif
 
#include <stm32f1xx_hal.h>
 
>>code<<
 
#ifdef __cplusplus
}
#endif
 
#endif

 console log at https://pastebin.com/iz2N4gpK

Weirdly enough it seems to work with some of my other libraries, don't know what is wrong with this one

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

The top-level file you should include is "stm32f1xx.h" which will include the others as needed.

> ../Inc/ltc6803LibF103.hpp:22:43: error: 'LTC6803_AMS' has not been declared

> ../Inc/ltc6803LibF103.hpp:23:4: error: 'MEAS_CV_Ident' has not been declared

> ../Inc/ltc6803LibF103.hpp:27:21: error: 'AMS_CFGR' has not been declared

> ../Src/ltc6803LibF103.cpp:36:14: error: 'CV' was not declared in this scope

None of these errors are about HAL stuff, they're all about your own things. Where are they defined?

The __cplusplus guards generally shouldn't be used prior to including header files. This is handled within the header files itself.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

3 REPLIES 3
TDK
Guru

The top-level file you should include is "stm32f1xx.h" which will include the others as needed.

> ../Inc/ltc6803LibF103.hpp:22:43: error: 'LTC6803_AMS' has not been declared

> ../Inc/ltc6803LibF103.hpp:23:4: error: 'MEAS_CV_Ident' has not been declared

> ../Inc/ltc6803LibF103.hpp:27:21: error: 'AMS_CFGR' has not been declared

> ../Src/ltc6803LibF103.cpp:36:14: error: 'CV' was not declared in this scope

None of these errors are about HAL stuff, they're all about your own things. Where are they defined?

The __cplusplus guards generally shouldn't be used prior to including header files. This is handled within the header files itself.

If you feel a post has answered your question, please click "Accept as Solution".
Ubus99
Associate III

Thanks, I will keep in mind to use stm32f1xx.h, but it doesn't fix my current problem.

The errors are mostly from my library, it is mostly complete, but the port to c++ messed some stuff up.

This is what it looks like in editor

0693W00000D1DDCQA3.jpgnever mind me trying to initialize spi as i2c, fixed it, but that's not the problem.

Ubus99
Associate III

Got it, I had to make the changes suggested by TDK, and then first refresh, then rebuild the index.