Problem of "multiple definition of ..." / "First defined here"

Discussions concerning TrueSTUDIO for STM32 9.0.0 and later versions.

Moderators: Markus Girdland, Mattias Norlander

sozbayraktar
Posts: 1
Joined: Wed Nov 14, 2018 10:13 am

Problem of "multiple definition of ..." / "First defined here"

Postby sozbayraktar » Wed Nov 14, 2018 10:34 am

Hi,

I couldn't resolve the issue of receiving following message at the end of compiling session:

Src\main.o:(.data.pKeypad1+0x0): multiple definition of `pKeypad1'
Drivers\Displays\TFT_SPI\tft.o:(.data.pKeypad1+0x0): first defined here
collect2.exe: error: ld returned 1 exit status

Following lines are in the tft.h file :

/* **** tft.h *** */

uint8_t ABCDE; // **** THIS DOES NOT CAUSE ANY PROBLEM

struct matrix{
uint8_t numberOfColumns;
uint8_t numberOfRows;
};

struct matrix keypad1;
struct matrix* pKeypad1=&keypad1; // **** BUT COMPILER COMPLAINS ABOUT THIS !

/* ******* Following are the first lines in main.c ***** */

/* Includes ------------------------------------------------------------------*/

#include "stm32f1xx_hal.h"
#include "tft.h"
....

When I move definition of pointer into tft.c, problem disapears but I want to understand what is the matter.

Does it handle pointers in a different way? Any help shall be appreciated.

Kind regards

Selcuk

EDIT: OK resolved, problem is not duplicate declarations. It does not accept the assignement to a declared variable or pointer here. It becames inclusion of a ".c" file within header. I did not remove the entry, that might be of interest to somebody else. BR

Return to “TrueSTUDIO for STM32 discussions”

Who is online

Users browsing this forum: No registered users and 1 guest