feiniao007 发表于 2010-9-29 15:15:58

keil 下编译sscanf的问题

芯片:LPC1765开发环境:keil4的 V4.03嵌入式系统:ucosii-2.52
有问题的代码段如下:
constchartemp2={'%','i','\0'};

int ImpCmd (uint32      uiID,
            char       *pcarg,
            uint32   *puiPara )
{
int         iArgc;
int         i,j;
int         iSucc=0;
uint32      uiNum;

char       *pcArgv;
          char       temp;
          char       temp3;


uiNum = GucCmdTabNum;                                       /* 获取命令参数表参数的个数   */

if ( pcarg == NULL || puiPara == NULL ) {
    return OPERATE_FAIL;
} else {
//         char temp;
      
      strcpy( temp, pcarg);                                           /* 拷贝用户参数进行修改         */
               
                  iArgc = CmdStr(temp, pcArgv);         
               }

for (i=0; i<iArgc; i++) {
for (j=0; j<uiNum; j++) {
                  
//   char    temp;
   
strcpy(temp3, Cmd_Tab);   
                              sscanf("ssss","%s",temp3);                        
strcat(temp3, temp2);                        
// if ( sscanf((char *)pcArgv,temp3,(puiPara+j)) != 0 ) {                                    
// iSucc ++;
// break;
// }
                           
}
}
                  LedOn(LED1);      
return iSucc;                                                       /* 解析完参数的个数             */
}


现象:编译正常,但是程序跑到sscanf("ssss","%s",temp3); 里就死掉了,如果屏蔽sscanf("ssss","%s",temp3); 则一切正常,不解中。
这里sscanf("ssss","%s",temp3); 这个句子是测试sscanf用的,发现只要有sscanf就死掉。

shandong 发表于 2010-10-12 11:35:22

看看你的任务堆栈是否是8字节对齐,UC默认是4字节对齐,估计改成8字节对齐就会好的
页: [1]
查看完整版本: keil 下编译sscanf的问题