2021-08-01 05:39 AM
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
Solved! Go to Solution.
2021-08-01 06:24 AM
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.
2021-08-01 06:24 AM
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.
2021-08-01 06:48 AM
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
never mind me trying to initialize spi as i2c, fixed it, but that's not the problem.
2021-08-01 07:43 AM
Got it, I had to make the changes suggested by TDK, and then first refresh, then rebuild the index.