2020-11-07 11:58 AM
Hello, I have a problem with a typedef struct.
I made a typedef struct :
typedef struct BMP280_HandleTypeDef
{
uint16_t dig_T1;
int16_t dig_T2;
int16_t dig_T3;
} BMP280_HandleTypeDef ;
In my function I declare the instance of it :
void myfunction
{
BMP280_HandleTypeDef dev;
...
MyFunction2(&dev); // I want to pass the pointer of the struct to an other function
}
// Prototype of MyFunction2
void MyFunction2 ( BMP280_HandleTypeDef *dev);
The compiler gives me this error:
error: unknown type name 'BMP280_HandleTypeDef'; did you mean 'I2C_HandleTypeDef'?
I use STM32CubeIde.
Thanks in advance for your help .
Pascal
Solved! Go to Solution.
2020-11-07 12:12 PM
The definition needs to appear before its first usage, so typedef struct needs to appear before you declare MyFunction2. The order you include files is going to be important here.
2020-11-07 12:12 PM
The definition needs to appear before its first usage, so typedef struct needs to appear before you declare MyFunction2. The order you include files is going to be important here.
2020-11-07 12:36 PM
Hello TDK. Yes it works !!
I had declarated the struct in my file .h at the end ; now I have declared at first and it works correctly. Thank you very much for your help.