ZStack项目链接时报错

问题遇到的现象和发生背景

IAR版本:8051,8.10
ZStack版本:2.3.0-1.4.0
现象:IAR构建ZStack项目时,编译通过,链接报错

报错内容

IAR在链接时报错:

Error[e27]: Entry "Control" in module AddressMenu ( D:\ZM\BSZigbee\Gateway\Projects\zstack\Samples\SampleApp\CC2530DB\CoordinatorEB-Pro\Obj\AddressMenu.r51) redefined in module OSAL_SampleApp ( D:\ZM\BSZigbee\Gateway\Projects\zstack\Samples\SampleApp\CC2530DB\CoordinatorEB-Pro\Obj\OSAL_SampleApp.r51 ) 
报错所涉及代码

1.OSAL_SampleApp.c

/*********************************************************************
 * INCLUDES
 */

#include "ZComDef.h"
#include "hal_drivers.h"
#include "OSAL.h"
#include "OSAL_Tasks.h"

#if defined ( MT_TASK )
  #include "MT.h"
  #include "MT_TASK.h"
#endif

#include "nwk.h"
#include "APS.h"
#include "ZDApp.h"
#if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )
  #include "ZDNwkMgr.h"
#endif
#if defined ( ZIGBEE_FRAGMENTATION )
  #include "aps_frag.h"
#endif

#include "SampleApp.h"

/*********************************************************************
 * GLOBAL VARIABLES
 */

// The order in this table must be identical to the task initialization calls below in osalInitTask.
const pTaskEventHandlerFn tasksArr[] = {
  macEventLoop,
  nwk_event_loop,
  Hal_ProcessEvent,
#if defined( MT_TASK )
  MT_ProcessEvent,
#endif
  APS_event_loop,
#if defined ( ZIGBEE_FRAGMENTATION )
  APSF_ProcessEvent,
#endif
  ZDApp_event_loop,
#if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )
  ZDNwkMgr_event_loop,
#endif
  SampleApp_ProcessEvent
};

const uint8 tasksCnt = sizeof( tasksArr ) / sizeof( tasksArr[0] );
uint16 *tasksEvents;

/*********************************************************************
 * FUNCTIONS
 *********************************************************************/

/*********************************************************************
 * @fn      osalInitTasks
 *
 * @brief   This function invokes the initialization function for each task.
 *
 * @param   void
 *
 * @return  none
 */
void osalInitTasks( void )
{
  uint8 taskID = 0;

  tasksEvents = (uint16 *)osal_mem_alloc( sizeof( uint16 ) * tasksCnt);
  osal_memset( tasksEvents, 0, (sizeof( uint16 ) * tasksCnt));

  macTaskInit( taskID++ );
  nwk_init( taskID++ );
  Hal_Init( taskID++ );
#if defined( MT_TASK )
  MT_TaskInit( taskID++ );
#endif
  APS_Init( taskID++ );
#if defined ( ZIGBEE_FRAGMENTATION )
  APSF_Init( taskID++ );
#endif
  ZDApp_Init( taskID++ );
#if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )
  ZDNwkMgr_Init( taskID++ );
#endif
  SampleApp_Init( taskID );
}

2.AddressMemu

/*********************************************************************
 * INCLUDES
 */
#include "SampleApp.h"
#include "SampleAppHw.h"

#include "OSAL.h"
#include "OSAL_Nv.h"
#include "ZComDef.h"
#include "ZGlobals.h"
#include "AF.h"
#include "aps_groups.h"
#include "ZDApp.h"

#include "OnBoard.h"


uint16 Get_BusAddress(void){
  
  uint16 Results = 0xFFF;     //总线地址,初始化为最大值
  
  return Results;
}


void AddressTable_Init(void){
  
  struct EquPar LocalTempBuf1, InitTempBuf1;
  uint8 InitNVStatus1 = osal_nv_item_init(ZD_NV_START_ADDRESS, sizeof(LocalTempBuf1), NULL);    //初始化本机信息条目
    
  if(InitNVStatus1 != NV_OPER_FAILED){     //判断读取成功
    
    if(InitNVStatus1 == SUCCESS){      //非首次组网
      
      osal_nv_read(ZD_NV_START_ADDRESS, 0, sizeof(LocalTempBuf1), &LocalTempBuf1);    //读取本机信息条目
      
      Local_Fun_Code = LocalTempBuf1.FunCode;
      Local_Address = LocalTempBuf1.Address;
      
    }
    else if(InitNVStatus1 == NV_ITEM_UNINIT){      //首次组网(本代码为网关)
      
      InitTempBuf1.FunCode = 0x0001;
      InitTempBuf1.Address = 0x000;
      
      osal_nv_write(ZD_NV_START_ADDRESS, 0, sizeof(InitTempBuf1), &InitTempBuf1);     //网关信息写入,网关地址永为0x000,网关功能码为0x0001
      
    }
    
  }
  
  struct AddressInfo LocalTempBuf2, InitTempBuf2;
  uint8 InitNVStatus2 = osal_nv_item_init(ZD_NV_START_ADDRESS+1, sizeof(LocalTempBuf2), NULL);      //初始化地址表头条目
    
  if(InitNVStatus2 != NV_OPER_FAILED){      //判断读取成功
    
    if(InitNVStatus2 == SUCCESS){     //非首次组网
      
      osal_nv_read(ZD_NV_START_ADDRESS+1, 0, sizeof(LocalTempBuf2), &LocalTempBuf2);      //读取原地址表头
      
      Gateway_Bus_Address = LocalTempBuf2.BusAddress;
      ZD_NV_OFFSET = LocalTempBuf2.OffsetAddress;
      
    }
    else if(InitNVStatus2 == NV_ITEM_UNINIT){     //首次组网(本代码为网关)
      
      InitTempBuf2.BusAddress = Get_BusAddress();
      InitTempBuf2.OffsetAddress = 2;
      ZD_NV_OFFSET = 2;
      
      osal_nv_write(ZD_NV_START_ADDRESS+1, 0, sizeof(InitTempBuf2), &InitTempBuf2);     //获取子网地址信息,偏移地址为3,并向服务器索取总线地址
    }
    
  }
  
  return;
}


void AddDevice(uint16 Type){
  
  struct EquPar DeviceTempBuf;
  uint8 InitNVStatus1 = osal_nv_item_init(ZD_NV_START_ADDRESS+ZD_NV_OFFSET, sizeof(DeviceTempBuf), NULL);     //新增一条地址表
  
  if(InitNVStatus1 == NV_ITEM_UNINIT){
    
    DeviceTempBuf.FunCode = Type;
    DeviceTempBuf.Address = 0x000 + ZD_NV_OFFSET - 1;
    
    osal_nv_write(ZD_NV_START_ADDRESS+ZD_NV_OFFSET, 0, sizeof(DeviceTempBuf), &DeviceTempBuf);
    //ZigbeeSend();
    ZD_NV_OFFSET++;
    
    struct AddressInfo TempBuf;
    uint8 InitNVStatus2 = osal_nv_item_init(ZD_NV_START_ADDRESS+1, sizeof(TempBuf), NULL);
    
    if(InitNVStatus2 == SUCCESS){
      
      TempBuf.BusAddress = Gateway_Bus_Address;
      TempBuf.OffsetAddress = ZD_NV_OFFSET;
      
      osal_nv_write(ZD_NV_START_ADDRESS+1, 0, sizeof(TempBuf), &TempBuf);
        
    }
  }
  return;
}

3.SampleApp.h

/*********************************************************************
 * INCLUDES
 */
#include "SampleAppHw.h"

#include "OSAL.h"
#include "OSAL_Nv.h"
#include "ZGlobals.h"
#include "AF.h"
#include "aps_groups.h"
#include "ZDApp.h"

#include "OnBoard.h"

/* HAL */
#include "hal_lcd.h"
#include "hal_led.h"
#include "hal_key.h"


#ifndef SAMPLEAPP_H
#define SAMPLEAPP_H

#ifdef __cplusplus
extern "C"
{
#endif

/*********************************************************************
 * INCLUDES
 */
#include "ZComDef.h"

/*********************************************************************
 * CONSTANTS
 */

// These constants are only for example and should be changed to the
// device's needs
#define SAMPLEAPP_ENDPOINT           20

#define SAMPLEAPP_PROFID             0x0F08
#define SAMPLEAPP_DEVICEID           0x0001
#define SAMPLEAPP_DEVICE_VERSION     0
#define SAMPLEAPP_FLAGS              0

#define SAMPLEAPP_MAX_CLUSTERS       2
#define SAMPLEAPP_PERIODIC_CLUSTERID 1
#define SAMPLEAPP_FLASH_CLUSTERID    2
#define SAMPLEAPP_COM_CLUSTERID      3
#define SAMPLEAPP_P2P_CLUSTERID      4
  
#define DATA_PIN P0_4                  //定义P0.5口为继电器的控制端

#define ZD_NV_START_ADDRESS 0x0402     //定义掉电存储起始条目地址
  
// Send Message Timeout
#define SAMPLEAPP_SEND_PERIODIC_MSG_TIMEOUT   1000     // Every 1 seconds

// Application Events (OSAL) - These are bit weighted definitions.
#define SAMPLEAPP_SEND_PERIODIC_MSG_EVT       0x0001
  
// Group ID for Flash Command
#define SAMPLEAPP_FLASH_GROUP                 0x0001
  
// Flash Command Duration - in milliseconds
#define SAMPLEAPP_FLASH_DURATION              1000
  

// This list should be filled with Application specific Cluster IDs.
const cId_t SampleApp_ClusterList[SAMPLEAPP_MAX_CLUSTERS] =
{
  SAMPLEAPP_PERIODIC_CLUSTERID,
};

void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pckt );

const SimpleDescriptionFormat_t SampleApp_SimpleDesc =
{
  SAMPLEAPP_ENDPOINT,              //  int Endpoint;
  SAMPLEAPP_PROFID,                //  uint16 AppProfId[2];
  SAMPLEAPP_DEVICEID,              //  uint16 AppDeviceId[2];
  SAMPLEAPP_DEVICE_VERSION,        //  int   AppDevVer:4;
  SAMPLEAPP_FLAGS,                 //  int   AppFlags:4;
  SAMPLEAPP_MAX_CLUSTERS,          //  uint8  AppNumInClusters;
  (cId_t *)SampleApp_ClusterList,  //  uint8 *pAppInClusterList;
  SAMPLEAPP_MAX_CLUSTERS,          //  uint8  AppNumInClusters;
  (cId_t *)SampleApp_ClusterList   //  uint8 *pAppInClusterList;
};

// This is the Endpoint/Interface description.  It is defined here, but
// filled-in in SampleApp_Init().  Another way to go would be to fill
// in the structure here and make it a "const" (in code space).  The
// way it's defined in this sample app it is define in RAM.
endPointDesc_t SampleApp_epDesc;

/*********************************************************************
 * LOCAL VARIABLES
 */
uint8 SampleApp_TaskID;   // Task ID for internal task/event processing
                          // This variable will be received when
                          // SampleApp_Init() is called.
devStates_t SampleApp_NwkState;

uint8 SampleApp_TransID;  // This is the unique message ID (counter)

afAddrType_t SampleApp_Periodic_DstAddr;
afAddrType_t SampleApp_Flash_DstAddr;

aps_Group_t SampleApp_Group;


uint8 SampleAppPeriodicCounter = 0;
uint8 SampleAppFlashCounter = 0;

/*********************************************************************
 * GLOBAL VARIABLES
 */
uint8 LedState = 0;                  //LED状态

uint8 FunState = 0;                  //风扇状态

uint8 Control = 0;                   //开关控制,0为一起,1为灯,2为风扇

uint16 ZD_NV_OFFSET = 0xFFF;         //掉电存储条目偏移,初始化最大

uint16 Local_Fun_Code = 0xFFFF;      //本机功能代码,初始化最大

uint16 Local_Address = 0xFFF;        //本机地址码,初始化最大

uint16 Gateway_Bus_Address = 0xFFF;  //子网总线地址,初始化最大
  
  
/*********************************************************************
 * STRUCTS
 */
  
//本机信息
struct EquPar
{
  uint16 FunCode;
  uint16 Address;
};

//地址功能表信息
struct AddressInfo
{
  uint16 BusAddress;
  uint16 OffsetAddress;
};

//数据包
struct Packet
{
  uint16 SourceAddress;
  uint16 TargetAddress;
  uint16 Type;
  uint16 Data;
  uint16 Verify;
};

struct Parket* ParketTempBuf = NULL;


extern void SampleApp_Init( uint8 task_id );

void SampleApp_HandleKeys( uint8 shift, uint8 keys );

/*********************************************************************
 * FUNCTIONS
 */

void SampleApp_SendPeriodicMessage( void );

extern UINT16 SampleApp_ProcessEvent( uint8 task_id, uint16 events );

extern void ReceiveData(struct Packet Data);

extern uint8 ZigbeeSend(uint16 Data, uint16 Address, uint16 Type);


extern uint16 Get_BusAddress(void);

extern void AddressTable_Init(void);

extern uint8* ConversionToRF(struct Packet Data);

extern void ConversionToData(uint8* Data);

extern void AddDevice(uint16 Type);


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

#ifdef __cplusplus
}
#endif

#endif /* SAMPLEAPP_H */
我想要达到的结果

请问这个链接报错如何解决?

在vc6.0中编译没报错,但运行有问题,在vs2003中编译报错.
下面 是代码.
这是一个表达式求解的程序.(利用运算符的优先级)
其中#是整个表达式求解完毕的标志.

#pragma warning(disable:4786)
#include
#include
#include
#include
#include<ctype.h>
using namespace std;
void main()
{
map<string, char>table;
table["++"]='>';
table["+-"]='>';
table["+"]='<';
table["+/"]='<';
table["+("]='<';
table["+)"]='>';
table["+#"]='>';
table["-+"]='>';
table["--"]='>';
table["-
"]='<';
table["-/"]='<';
table["-("]='<';
table["-)"]='>';
table["-#"]='>';
table["+"]='>';
table["
-"]='>';
table["**"]='>';
table["/"]='>';
table["
("]='<';
table[")"]='>';
table["
#"]='>';
table["/+"]='>';
table["/-"]='>';
table["/"]='>';
table["//"]='>';
table["/("]='<';
table["/)"]='>';
table["/#"]='>';
table[")+"]='>';
table[")-"]='>';
table[")
"]='>';
table[")/"]='>';
table["))"]='>';
table[")#"]='>';
table["(+"]='<';
table["(-"]='<';
table["("]='<';
table["(/"]='<';
table["(("]='<';
table["()"]='=';
table["#+"]='<';
table["#-"]='<';
table["#
"]='<';
table["#/"]='<';
table["#("]='<';
table["##"]='=';

stack num;
stack alp;
alp.push('#');

string s="2+4-(4-4*3)/4";
s+='#';
int i=0;
char c=s[i++];

while(c!='#'||(alp.top)!='#')//这句报错.
{
if(isdigit(c))
{
num.push((float)c-48);
c=s[i++];
}
else
{

string s1;
s1+=alp.top();
s1+=c;
char c1=table[s1];

switch(c1)
{
case'<':
alp.push(c);
c=s[i++];
break;
case'=':
alp.pop();
c=s[i++];
break;
case'>':
float x=num.top();
num.pop();
float y=num.top();
num.pop();
char c2=alp.top();
alp.pop();
switch(c2)
{
case'+':
x=x+y;
break;
case'-':
x=x-y;
break;
case'':
x=x
y;
break;
case'/':
x=x/y;
break;
}
num.push(x);

break;

}
}

}
cout<<num.top();
}

我也不太清楚是那些问题 但愿这篇文章可以帮助到你

IAR编译Z-stack出错问题及解决方法汇总
https://blog.csdn.net/qq_33194301/article/details/103328959