ICCAVR Error:multiple define

Error:

F:\iccv7avr\bin\imakew -f RF_P1.mak

iccavr -o RF_P1 -g -ucrtatmega.o -bfunc_lit:0x68.0x1000 -dram_end:0x4ff -bdata:0x100.0x4ff -dhwstk_size:16 -beeprom:0.512 -fihx_coff -S2 @RF_P1.lk -lcatmega

!E nRF24L01.o(273): multiple define: ‘_ackpldbuf’

!E nRF24L01.o(274): multiple define: ‘_p1_txAdd’

!E nRF24L01.o(275): multiple define: ‘_p2_txAdd’

!E nRF24L01.o(276): multiple define: ‘_p3_txAdd’

!E nRF24L01.o(277): multiple define: ‘_p1_PhyAdd’

!E nRF24L01.o(278): multiple define: ‘_p2_PhyAdd’

!E nRF24L01.o(279): multiple define: ‘_p3_PhyAdd’

!E nRF24L01.o(280): multiple define: ‘_BroadcastAdd’

F:\iccv7avr\bin\imakew.exe: Error code 1

Done: there are error(s). Exit code: 1. Wed May 28 11:58:44 2008

my rf_p1.c is:

//**************************************************************

// nRF24L01 communication PTX

// Target: ATMEGA168V FOSC:1 MHz

//**************************************************************

#include<iom168v.h>

#include<macros.h>

#include<string.h>

#include “myfun.h”

#include “uart.h”

#include “spi.h”

#include “nRF24L01.h”

nRF24L01.h is:

//******************************************************************//

//nRF24L01.h

//Creat time: 2008.05.21

//******************************************************************//

#pragma once

#ifndef __NRF24L01_H

#define __NRF24L01_H

nRF24L01.c is:

//******************************************************************//

//nRF24L01.c

//Creat time: 2008.05.15

//******************************************************************//

#include <iom168v.h>

#include “myfun.h”

#include “uart.h”

#include “spi.h”

#include “nRF24L01.h”

The variable multiple defined is define in nRF24L01.h.

Can anyone help me?

regarding

#pragma once

that’s proprietary to IAR. What does it do?

I read that #pragma once will comiple the following file only once,so I add it.But it seems doesnot work.

And,the multiple define error still exists,when I remove that sentence.

I add

#ifndef __NRF24L01_H

#define __NRF24L01_H

#endif

but,it seems cannot work.Both in nRF24L01.s and rf_p1.s files,there are those multiple define variables.It seems only one of them should have those variables.Why?

Thanks!

#ifndef __NRF24L01_H

#define __NRF24L01_H

#endif

only helps protect against including a .h file multiple times in a .c file.

It looks like you include nRF24L01.h in both my rf_p1.c and nRF24L01.c

so each one tries to declare its own copy of the variable.

What you probably want to do is define it once, say in nRF24L01.c, and declare it extern in the other file.

I define struct definition,macro definition in .h,define variables in .cpp,then declare it in .h using extern.Thus, everything is OK.

Thanks again!