• AVR Freaks

AnsweredHot!Error Message "symbol "x@y" defined more than once"

Author
gruf
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2019/12/09 03:08:34
  • Location: 0
  • Status: offline
2020/01/24 05:23:46 (permalink)
0

Error Message "symbol "x@y" defined more than once"

Hello Everyone, 
 
I'm biting my teeth out on these error messages:
C:\Program Files (x86)\Microchip\xc8\v2.10\pic\include\pic16f18425.h:30742:: error: (845) symbol "flags@CALIBRATION_FAULT" defined more than once
C:\Program Files (x86)\Microchip\xc8\v2.10\pic\include\pic16f18425.h:30745:: error: (845) symbol "flags@SENSOR_STATUS" defined more than once
C:\Program Files (x86)\Microchip\xc8\v2.10\pic\include\pic16f18425.h:30748:: error: (845) symbol "flags@SYSTEM_STATUS" defined more than once

 
When clicking on the error message, it takes me to pic16f18425.h, at lines 30742, 30745 and 30748. On all three of these lines, nothing is named like the structs in flags.h .
 
The header file flags.h looks like this:
#ifndef FLAGS_H
#define FLAGS_H

#include <stdint.h>

typedef struct {
 uint8_t FRESH_DATA_AVAILABLE :1;
 uint8_t ph :7; //placeholder to reach full byte
} system_status_t;
static volatile system_status_t SYSTEM_STATUS;

typedef struct{
 uint8_t S0C0 :1;
 uint8_t S0C1 :1;
 uint8_t S0C2 :1;
 uint8_t S0C3 :1;
 uint8_t S1C0 :1;
 uint8_t S1C1 :1;
 uint8_t ph :2; //placeholder to reach full byte
} sensor_status_t;
static volatile sensor_status_t SENSOR_STATUS;

typedef struct{
 uint8_t S0C0 :1;
 uint8_t S0C1 :1;
 uint8_t S0C2 :1;
 uint8_t S0C3 :1;
 uint8_t S1C0 :1;
 uint8_t S1C1 :1;
 uint8_t ERROR :2;
} cal_fault_t;
static volatile cal_fault_t CALIBRATION_FAULT;

#endif

 
I tried swapping the include guards with a 
#pragma once
, but that did not help - neither did both include guards and pragma at the same time.
 
When removing the declaration for SYSTEM_STATUS for example, the compiler sends following error message:
error: use of undeclared identifier 'SYSTEM_STATUS'
which makes no sense, since it says that the symbol is defined more than once.
 
After spending some time with googling, I've read that the compiler is just broken, but I don't want to believe that.
Does anyone know what might be the issue here?
 
I'm using XC8 v2.10 with MPLAB X IDE v5.10 on Win10.
My Target Device is a PIC16F18425.
#1
JPortici
Super Member
  • Total Posts : 894
  • Reward points : 0
  • Joined: 2012/11/17 06:27:45
  • Location: Grappaland
  • Status: offline
Re: Error Message "symbol "x@y" defined more than once" 2020/01/24 05:48:09 (permalink)
+1 (1)
Yes, I have a couple of things in mind
 
1) are you by any chance including a specific pic include file (something like p16f18345.h)?
don't.
include xc.h and only xc.h
 
maybe you mispelled the pic or used a different pic in the beginning and then changed it. xc.h takes care of selecting the correct file.
 
2) are you by any chance using ctrl+space for autocomplete? Check ALL the files in the project to see if there is a rogue pic include file, possibly for a different pic.
Go to Tools -> Options -> Editor -> Code Completition. Select C from the language list and then remove the tick on "Auto insert include directives"
There is a long standing issue in netbeans which nobody knows how to trigger because it's so sporadic.
The first time it happened it took me ages to find out why, the damn include hid itself very well.
 
Do this fix anyway to prevent the issue from ever happening.
 
#2
gruf
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2019/12/09 03:08:34
  • Location: 0
  • Status: offline
Re: Error Message "symbol "x@y" defined more than once" 2020/01/24 05:59:20 (permalink)
0
Thanks for the quick reply, but your suggestions didn't help.
 
I checked all the files within the project, and no specific p*.h file is included anywhere.
I also did not edit any file provided from microchip.
#3
ric
Super Member
  • Total Posts : 25592
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Error Message "symbol "x@y" defined more than once" 2020/01/24 13:55:23 (permalink)
+2 (2)
I have no idea why the error is reported in pic16f18425.h
I think that is a red herring.
The real error is that you have variable definitions inside your header file.
Header files should only contain not declarations, not definitions.
i.e. a header file should NEVER allocate storage.
The matching definition must be in ONE of your C files.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#4
LdB_ECM
Super Member
  • Total Posts : 236
  • Reward points : 0
  • Joined: 2019/04/16 22:01:25
  • Location: 0
  • Status: offline
Re: Error Message "symbol "x@y" defined more than once" 2020/01/24 22:52:07 (permalink) ☼ Best Answerby gruf 2020/01/26 22:57:10
+3 (3)
The error is correct those entries can't be static ... you are trying to expose a static as a public and no doubt access it from other units.
 
Solution in the flags.h file declare them as extern  so in the .h file like so
extern volatile system_status_t SYSTEM_STATUS;
extern volatile sensor_status_t SENSOR_STATUS;
extern volatile cal_fault_t CALIBRATION_FAULT;

 
Now open flags.c, if you don't have one make one and make sure it contains these

#include "flags.h"
volatile system_status_t SYSTEM_STATUS;
volatile sensor_status_t SENSOR_STATUS;
volatile cal_fault_t CALIBRATION_FAULT;

 
Problem solved.
post edited by LdB_ECM - 2020/01/24 23:04:27
#5
gruf
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2019/12/09 03:08:34
  • Location: 0
  • Status: offline
Re: Error Message "symbol "x@y" defined more than once" 2020/01/26 23:02:19 (permalink)
0
Thanks a lot LdB_ECM, everything is working now.
#6
Jump to:
© 2020 APG vNext Commercial Version 4.5