 | Discussion Forum |  |
|
|
Macro guard not workingNext Thread | Thread List | Previous Thread Start a Thread | Settings | Details | Message |
|---|
Read-Only Author Simon O'Neill Posted 22-Nov-2008 04:54 GMT Toolset C51 |  Macro guard not working Simon O'Neill Hello everyone, I am having problem with a multiple public definition: ERROR L104: MULTIPLE PUBLIC DEFINITIONS SYMBOL: currenpacketbeingsampled MODULE: DataSampling.obj (DATASAMPLING) DEFINED: Main.obj (MAIN) The variable in question is defined only once in the header file, and only used in the associated C file. From my understanding a macro guard should prevent the error that i am getting. The header file code is shown below, can anyone see a reason why i would be getting the error??? Thanks.
#ifndef DS_H
#define DS_H
#include <stdio.h>
#include <stdlib.h>
#include "hal.h"
#include "cc1010eb.h"
#include "Reg1010.h"
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL 0
#endif
#define AD0ECG 1
#define AD1PULSE 2
#define AD2TEMPSENSOR 3
#define AD2RSSI 4
void InitialiseDataSampling(byte xdata DataTypes);
void SampleData(bool xdata condition);
void SetupADC(char SetupType);
extern byte xdata ECGcount; //The destination element of the next ECG data in ECGsamples[]
extern byte xdata TEMPcount; //The destination element of the next temperature data in TempData[]
char xdata currentpacketbeingsampled;
extern char xdata nextpackettosend;
extern byte xdata DataSampled;
extern short int ECGsamples[50];
extern int maximumvalue;
#endif //DS_H
| | Read-Only Author Jon Ward Posted 22-Nov-2008 13:18 GMT Toolset C51 |  RE: Macro guard not working Jon Ward DS_H prevents the contents of the header from being included more than once in a single C file. But what prevents currentpacketbeingsampled from being declared in each C file where this header is included? Jon | | Read-Only Author Andy Neil Posted 22-Nov-2008 13:25 GMT Toolset None |  Fundamental flaw Andy Neil "The variable in question is defined only once in the header file" (my emphasis) That's your problem! You should not define variables in the header file - otherwise, as Jon says, every file which includes that header will have a definition of the variable! Your header should contain only declarations - see: http://c-faq.com/decl/decldef.html Note that this is bog standard 'C' - nothing specifially to do with Keil or C51... | | Read-Only Author Per Westermark Posted 22-Nov-2008 15:50 GMT Toolset None |  RE: Fundamental flaw Per Westermark In short, you forgot the extern keyword on this specific line:
char xdata currentpacketbeingsampled;
Compare with the other lines. | | Read-Only Author Simon O'Neill Posted 22-Nov-2008 21:13 GMT Toolset C251 |  RE: Fundamental flaw Simon O'Neill Thank you for your help. | |
Next Thread | Thread List | Previous Thread Start a Thread | Settings |
|