cancel
Showing results for 
Search instead for 
Did you mean: 

Error with pointer to a typedef struct

Prisma
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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.

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

View solution in original post

2 REPLIES 2
TDK
Guru

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.

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

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.