cancel
Showing results for 
Search instead for 
Did you mean: 

ModusToolbox™ General

Gopi
New Contributor II

hii,

i have taken the sample CSD capsense tuning example, and i have created a folder named as "driver" in that project itself which has inc and src folder which contains the .h and .c driver files in that folders.

and my issue here is i have crated a variable in some gpio.h and i have included that file in gpio.c and in main.c and after i build the code it was giving as error like first defined here like that.  i dont know what is the problem.

does i need to include the paths of driver folder or i need to make any changes in the IDE to get resolved. please help me to solve this.

Thanks in advance.

0 Likes
1 Reply
AlenAn14
Moderator
Moderator

Hi @Gopi ,

I believe you are using ModusToolbox v 2.4 (Correct me if I am wrong).
It uses the latest GCC 10.3 which does not support the declaration/definition of variables in header files unlike GCC version 9.3.1 used in ModustToolbox 2.2 and hence will give multiple definition error when this header file containing variable declaration is included in multiple source files (.c files).

Please do the following to rectify this issue:
1. Declare the variable in gpio.c instead of declaring it in gpio.h.
If the variable you created is an integer variable named 'myVariable',  then it should be declared in gpio.c as follows:
int myVariable;

2. In the header file gpio.h create the declaration for this variable as extern as follows:
extern int myVariable ;

Now the variable myVariable can be used in both main.c and gpio.c without this error comming up during build.

Hope this helps!
Regards
Alen

0 Likes