cancel
Showing results for 
Search instead for 
Did you mean: 

how to make 2 headers in stm32cubeide include each other?

TNguy.30
Associate

Hello guys!

I am now using stm32cubeide and the issue is that there are 2 headers and I need them to include each other but when I do that, the compiler indicates that my typedef struct defined in a header is conflicting types. I have used this preprocess syntax for each header:

"

#indef _Header_H_

#define _Header_H_

#endif 

"

but it's not working. Does anyone know how to solve this?

4 REPLIES 4
Piranha
Chief II

Exactly like with every other IDE, compiler and googleplex examples in the Internet... Obviously #endif must be at the end of the file.

Also take a look on this:

https://stackoverflow.com/questions/1143936/pragma-once-vs-include-guards

https://stackoverflow.com/questions/787533/is-pragma-once-a-safe-include-guard

mehmet.karakaya
Associate III

Hi, I have same error

I include a header file in several .c files

it gives error - multiple definition

I tried to make an "include guard" as below

however multiple definiton error again

CubeIDE gcc STM32F103

please advice , thanks

#ifndef INC_US_GLOBAL_H_
#define INC_US_GLOBAL_H_
 
uint8_t RAM[0x1e00],RLO;
int16_t  ACCU1 , ACCU2 , PARAM1,ikl=0;
uint8_t TIMERSTART[128], TIMEROUT[128];uint16_t TIMERSET[128];
unsigned char toggle, toggleLED=1,pai;
 
.............
 
uint8_t Rx_buffer[512], Rx_buffer_3[20];
volatile uint8_t TIMERJOB, Tx_buffer_2[512];
volatile int16_t Rx_ptr_2,counterhi;//ADCresult;
 
#endif // INC_US_GLOBAL_H_

Perhaps stop defining things in .H files, keep that in ONE .C file, and use extern in the .H files!!

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
  1. int16_t ACCU1 , ACCU2 , PARAM1,ikl=0;
  2. uint8_t TIMERSTART[128], TIMEROUT[128];uint16_t TIMERSET[128];
  3. unsigned char toggle, toggleLED=1,pai;

Don't Do This!

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..