2022-10-25 10:17 PM
I want to work by adding the c and h files I created.
The problem is that the variables and header files declared in ".h" cannot be loaded from the ".c" file.
Below is the situation I tested.
The c and h files I created are core.c and core.h.
not problem As shown in the figure, there was no problem when "components.h" and "stdio.h" were included in the core.c file and variables were declared.
However, an error occurred when variables declared in core.h and header files were included.
I would like to ask for help on how to solve it.
Solved! Go to Solution.
2022-10-25 11:45 PM
Hello, annyeonghaseyo,
the first quick work around is to use:
#include "../include/core.h"
But I will look how to fix Makefile to extend include directories.
got bwayo
Best regards.
2022-10-25 11:13 PM
Defining a global variable in a header file often causes trouble and is generally not recommended or even forbidden in some domains, like MISRA C, see https://analyst.phyzdev.net/documentation/help/reference/misra.onedefrule.var.htm
There seems to be another issue in your code as the compiler warns about printf which should be declared in stdio.h. ...
hth
KnarfB
2022-10-25 11:45 PM
Hello, annyeonghaseyo,
the first quick work around is to use:
#include "../include/core.h"
But I will look how to fix Makefile to extend include directories.
got bwayo
Best regards.
2022-10-25 11:48 PM
This is also true
the variable should be declared in the .h (extern uint8_t abcd;)
and instantiated in the .c (uint8_t abcd = 255;)
2022-10-25 11:57 PM
thank you
2022-10-26 01:02 AM
I found the root cause of your issue:
we already have a core.h in our sample code
so you need to rename your file (eg mycore.h)
and include it
#include "mycore.h"
Best regards,
-Olivier