DSPwilliam hill官网
直播中

第七子dqz

5年用户 6经验值
擅长:可编程逻辑 嵌入式技术 处理器/DSP 控制/MCU
私信 关注

ccsv5.5仿真c5535中sizeof返回值不正确

使用ccsv5.5版本仿真c5535的板子,sizeof(int)是1,float是2,double也是2,用ccsv6版本仿真c5535会闪退,但是仿真c6713是没有问题的。有没有大神可以帮解决一下,让v5.5sizeof返回值正确或者让v6.0顺利仿真c5535都可以,跪谢!

已经尝试过使用int16_t但是sizeof是1,下面是main函数部分
  1. #include "codec2.h"


  2. #include
  3. #include
  4. #include
  5. #include
  6. //#include


  7. int main()
  8. {
  9.     int            mode;
  10.     void          *codec2;
  11.     FILE          *fin;
  12.     FILE          *fout;
  13. //    short         *buf;
  14.     short                  *buf;
  15.     unsigned char *bits;
  16.     int            nsam, nbit, nbyte, gray;
  17.     int            i = 0;

  18.         char file_in1[40] = "E:\voice_test\nihao.raw";
  19.         char file_out1[40] = "E:\voice_test\shengcheng\nihao_ccs.c2";
  20.         

  21.         mode = CODEC2_MODE_3200;


  22.    
  23.         fin = fopen(file_in1,"rb");

  24.     fout = fopen(file_out1,"wb");

  25.     codec2 = codec2_create(mode);
  26.     nsam = 160;
  27.     nbit = 64;
  28.     buf = (short*)malloc(nsam*sizeof(short));
  29.     nbyte = (nbit + 7) / 8;

  30.     size_t j = sizeof(nsam);
  31.     size_t k = sizeof(float);
  32.     size_t h = sizeof(int32_t);
  33.     size_t l = sizeof(char);

  34.     bits = (unsigned char*)malloc(nbyte*sizeof(char));

  35.     gray = 1;
  36.     codec2_set_natural_or_gray(codec2, gray);

  37.     while(fread(buf, sizeof(short), nsam, fin) == (size_t)nsam) {

  38.             i++;
  39.         codec2_encode_3200(codec2, bits, buf);



  40.         fwrite(bits, sizeof(char), nbyte, fout);
  41.         if (i == 10)
  42.                 i = 0;
  43.         // if this is in a pipeline, we probably don't want the usual
  44.         // buffering to occur

  45.         if (fout == stdout) fflush(stdout);
  46.         if (fin == stdin) fflush(stdin);
  47.     }

  48.     codec2_destroy(codec2);

  49.     free(buf);
  50.     free(bits);
  51.     fclose(fin);
  52.     fclose(fout);


  53.     return 0;
  54. }




更多回帖

发帖
×
20
完善资料,
赚取积分