This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Redefinition error when exceeding array size

i am controlling a touchpanel via spi, communication works fine.

Defining the buffers for RX and TX like :

uint16 TX_DataMaster[16];
uint16 RX_DataMaster[16];

works but when the array size exceeds the value of 16 the compiler returns an error like....

Description Resource Path Location Type
#10056 symbol "TX_DataMaster" redefined: first defined in "./source/spi_DPP-CT1060A.obj"; redefined in "./source/sys_main.obj"	DPP-CT1060A	C/C++ Problem

Include guards are used, too! 

This is the header:

/*
_____HEADER____
#####################################
Display Driver
Demmel Products CT1060A - Binary Mode
Interface: SPI
Jan Scharnweber - 2014
#####################################
*/
//
/*##### Current SPI Settings#####
 * Wdelay: 0
 * Charlen: 8 Bit (using binary mode)
 * VCLK1: 100 MHz
 * Prescale: 255
 * Baudrate: 390.625 KHz
 * MSB first
 * Wait for enable: no
 * Parity: no
 * Clock Phase: 0
 * Clock Polarity : 0
 * SPI Mode 0 Master
 *
 */

// Queue length: 127Byte (127 + <CID>)
// Format: <CID> Comand 1 Command X

// always wait for ACK from TouchPanel
// no syntax check is provided


//Includes
/*ToDo:
- implement include guards
-
*/

#ifndef SPI_DPP_CT1060A_
#define SPI_DPP_CT1060A_

#include "sys_common.h"

#include "spi.h"
#include "stdio.h"
#include "utils.h"

/*Flags*/
static bool fDISP_RX_READY = false;
static bool fDISP_TX_READY = false;

/*Header and Trailer*/
#define ACK 0x06 	// Acknowledgment
#define NACK 0x15 	// Negative Acknowledgment


spiDAT1_t dataconfig1_t; // SPI config (also see HCG Settings)
uint16 TX_DataMaster[17]; // SP transmitting buffer
uint16 RX_DataMaster[1]; // SP receiving buffer

/*Functions*/

void DISP_InitSPI(void);

bool DISP_CheckStatController(spiBASE_t* spiPort);

void DISP_SendByte(uint16* byteToSend);

bool DISP_SendCommand(unsigned char *buf, unsigned char length);
/**/

#endif // _SPI_DPP_CT1060A_

Both array are defined only ONCE!

What am i doing wrong??

Thanks

Jan

 

  • Jan,

    Please check if this header file is included in multiple source code file. If it is included in multiple source files, the variable defined in the header file will be defined multiple times. You should not define those arrays in the source file because they are already defined in the header.

    Thanks and regards,

    Zhaohong

  • Hello,

    thank you for the very quick response.

    As i wrote i'm using include guards and the array is only defined in the header. But i can compile as long as the array size does not exceeds 16. Why?? E.g. when coding uint16 TX_Data_Master[17] the compiler returns an error.

    thanks

    Jan