遇到的编译错误或警告(小集锦)

    xiaoxiao2021-08-14  111

    一 错误

    1、error: return type is an incomplete type

    翻译过来是:返回类型是不完整的类型。

    我这里出现的原因是,在写函数接口的时候,返回的是结构体指针,但是在定义函数返回类型的时候,只写了对应的结构体。

    错误代码如下:

     

    struct SwrContext swr_config(struct SwrContext *s, AVFormatContext *ic, S32 stream_index) { if(NULL == s) { s = swr_alloc(); } s = swr_alloc_set_opts(s, // we're allocating a new context AV_CH_LAYOUT_STEREO, // out_ch_layout AV_SAMPLE_FMT_S32, // out_sample_fmt SWR_SAMPLE_RATE, // out_sample_rate ic->streams[stream_index]->codec->channel_layout, // in_ch_layout ic->streams[stream_index]->codec->sample_fmt, // in_sample_fmt ic->streams[stream_index]->codec->sample_rate, // in_sample_rate 0, // log_offset NULL); // log_ctx swr_init(s); return s; }

     

     

     

    错误提示为:

    decoder1.c:52:19: error: return type is an incomplete type struct SwrContext swr_config(struct SwrContext *s, AVFormatContext *ic, S32 stream_index)                   ^decoder1.c: In function ‘swr_config’:decoder1.c:69:9: warning: ‘return’ with a value, in function returning void  return s;

    更改后的代码为:

     

    struct SwrContext *swr_config(struct SwrContext *s, AVFormatContext *ic, S32 stream_index) { if(NULL == s) { s = swr_alloc(); } s = swr_alloc_set_opts(s, // we're allocating a new context AV_CH_LAYOUT_STEREO, // out_ch_layout AV_SAMPLE_FMT_S32, // out_sample_fmt SWR_SAMPLE_RATE, // out_sample_rate ic->streams[stream_index]->codec->channel_layout, // in_ch_layout ic->streams[stream_index]->codec->sample_fmt, // in_sample_fmt ic->streams[stream_index]->codec->sample_rate, // in_sample_rate 0, // log_offset NULL); // log_ctx swr_init(s); return s; }

     

    2、unrecognized argument in option ‘mcmode=kernel’

    在编译内核驱动时,报该错误

    通过在编译命令 增加option ARCH=arm 解决

     

    二 警告

     

    三 编码规范

    NOTE:这里的编码规范是指,如果不按照,有时就回出现错误

    1 结构体指针在声明的时候,必须赋为NULL。

    原因:如果不赋为NULL,不同的编译器在处理结构体声明的时候,有的会自动赋为空,有的会赋一个值(影响申请内存的过程)。

     

     

     

     

    转载请注明原文地址: https://ju.6miu.com/read-676318.html

    最新回复(0)