繁体   English   中英

How to fix these error “Implicit declaration of function is invalid in C99” and “Conflicting types” in.c file in Xcode objective-C?

[英]How to fix these error “Implicit declaration of function is invalid in C99” and “Conflicting types” in .c file in Xcode objective-C?

Actually iam importing.C file library in objective-c.I have fixed most of errors.but below two errors iam not able to resolve.. The first one is: "Implicit declaration of function 'read_binary_profile' is invalid in C99"

第二个是:“'read_binary_profile' 的冲突类型”

你能帮忙解决这个问题吗?

下面是代码

    #include <math.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    #include <time.h>
    #define __EXTRA_CMDL_SERVICE
    #define __TEXT_ERRORS_PRINT

    #include "profile.h"
    #include "vcp-api.h"
    #define PROFILE "/vendor/etc/profile.bix"
    extern char* vcp_errorv(err_t err);
    vcp_profile_t* read_binary_profile(void* pmem, int allocate);

    vcp_profile_t *p;
    void *b_profile ;
    mem_reg_t reg[NUM_MEM_REGIONS];
    void *smr[NUM_MEM_REGIONS];
    #define FRAME_VCP  80//120      //  Frame handle lenght 120: 7.5ms 16Bit, 16K  so defined here,   but buffer lenght is 120* size of short
    short *input_frame[4];
    short *spk[2];
    short aec[FRAME_VCP] ;   //¥À¥¶»Áπ˚√ª”–ACE , ø…“‘”√ø’ ˝◊È

    void alango_vcp_init()
{
    unsigned int smem = 16000; //1792;
    void *mem;
    err_t err;
    FILE *fp, *fp2 ;
    int flen , fsize ;

    fp=fopen(PROFILE,"rb");
    fseek(fp,0,SEEK_END);
    flen=ftell(fp);
    b_profile=(char *)malloc(flen);
    if(b_profile==NULL){
        fclose(fp);
        printf("Alango VCP Can't find profile configuration.\n");
        return ;
    }
    if(fp==NULL){
        printf("Alango VCP Can't open profile configuration.\n");
        return ;
    }
    fseek(fp,0,SEEK_SET);
    fsize=fread(b_profile,1,flen,fp);
    if(fsize!=flen){
        printf("read file error , read len ==== %d , return size ===%d", flen, fsize);
        fclose(fp);
        return;
    }
    p=read_binary_profile(b_profile,0);
    printf("alango_vcp_init 111 \n");
    err = vcp_check_profile(p);
    printf("alango_vcp_init 222 \n");
    if (err.err){
         if (err.err == ERR_INVALID_CRC)
             printf("alango_vcp_init Profile error: Invalid CRC!");
         else
             printf("alango_vcp_init Profile error: vcp_errorv(err) \n");
    }
    smem = vcp_get_hook_size();
    mem = malloc(smem);
    printf("alango_vcp_init 333 \n");
        vcp_get_mem_size(p, reg, mem);
        printf("alango_vcp_init 444 \n");
    free(mem);

    input_frame[0] = malloc(FRAME_VCP*sizeof(short));    //  5ms 16K 16bit buffer
    input_frame[1] = malloc(FRAME_VCP*sizeof(short));    //  5ms 16K 16bit buffer
    input_frame[2] = malloc(FRAME_VCP*sizeof(short));    //  5ms 16K 16bit buffer
    input_frame[3] = malloc(FRAME_VCP*sizeof(short));    //  5ms 16K 16bit buffer
    spk[0] = malloc(FRAME_VCP*sizeof(short));    //  5ms 16K 16bit buffer
    spk[1] = malloc(FRAME_VCP*sizeof(short));    //  5ms 16K 16bit buffer
    for (int i = 0; i < NUM_MEM_REGIONS; i++){
        reg[i].mem = smr[i] = (void *)malloc(reg[i].size);
        printf("alango_vcp_init I need %d bytes of memory in memory region %d to work.\n", reg[i].size, i + 1);
    }
    err = vcp_init_debug(p, reg);
    if (err.err == ERR_NOT_ENOUGH_MEMORY)
    {
        printf("alango_vcp_init %d more bytes needed in region %d!\n", -reg[err.pid].size, err.pid);
    }
    else if (err.err == ERR_UNKNOWN)
    {
        printf("alango_vcp_init vcp_init_debug() returns UNKNOWN error\n!");
    }
    else if (err.err != ERR_NO_ERROR)
    {
        printf("alango_vcp_init vcp_init_debug() returns error __text_error[err.err], err.pid!\n");
    }
}



    vcp_profile_t * read_binary_profile(void *pmem, int allocate)
    {
       vcp_profile_t *prof;//base_profile();
       prof= malloc(sizeof(profile_tab));
    }

通过声明方法解决该错误后,它显示以下错误

ld: warning: ignoring file /Users/yq12462/Desktop/ImportingCfileDemo/ImportingCfileDemo/libvcp_32.a, building for iOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
ld: warning: ignoring file /Users/yq12462/Desktop/ImportingCfileDemo/ImportingCfileDemo/libvcp_64.a, building for iOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
Undefined symbols for architecture arm64:
  "_vcp_check_profile", referenced from:
      _alango_vcp_init in AlangoBasic.o
  "_vcp_get_hook_size", referenced from:
      _alango_vcp_init in AlangoBasic.o
  "_vcp_get_mem_size", referenced from:
      _alango_vcp_init in AlangoBasic.o
  "_vcp_init_debug", referenced from:
      _alango_vcp_init in AlangoBasic.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

“函数的隐式声明”意味着当您调用 function 时,编译器看不到 function 声明。 自 C99 标准以来,C 不再允许这样做。

显然,在面对这样的 function 调用时,您的编译器仍会尝试从中生成旧的 C90“隐式 int”,这意味着在发现此p=my_read_binary_profile(b_profile,0)时,它将把 function 视为声明为int my_read_binary_profile (int, int)并相应地生成机器码,这显然是错误的。

这给出了第二个错误,“隐式 int”废话与正确的 function 定义vcp_profile_t * my_read_binary_profile(void *pmem, int allocate)不匹配,因此类型冲突。

通过在文件顶部添加 function 声明原型来解决此问题:

vcp_profile_t* my_read_binary_profile(void* pmem, int allocate);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM