how to make 2 headers in stm32cubeide include each other?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-13 10:42 AM
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?
- Labels:
-
STM32CubeIDE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-01-13 11:19 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-23 11:41 AM
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_
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-23 12:21 PM
Perhaps stop defining things in .H files, keep that in ONE .C file, and use extern in the .H files!!
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-23 12:23 PM
- int16_t ACCU1 , ACCU2 , PARAM1,ikl=0;
- uint8_t TIMERSTART[128], TIMEROUT[128];uint16_t TIMERSET[128];
- unsigned char toggle, toggleLED=1,pai;
Don't Do This!
Up vote any posts that you find helpful, it shows what's working..
