zoukankan      html  css  js  c++  java
  • error C2054: 在“inline”之后应输入“(”

    #include <stdio.h>
    #include <libavformat/avformat.h>
    /*
    extern "C"
    {
    #include <libavformat/avformat.h>
    }
    */
    
    int main(int argc, char **argv)
    {
    	AVFormatContext *fmt_ctx = NULL;
    	int ret;
    
    	av_register_all();
    	if ((ret = avformat_open_input(&fmt_ctx, "bad.mp4", NULL, NULL)))
    		return ret;
    
    
    	avformat_close_input(&fmt_ctx);
    	return 0;
    }


    出现以下错误:

    1>g:codingffmpegffmpeg-20160413-git-0efafc5-win32-devincludelibavutilerror.h(109): error C2054: 在“inline”之后应输入“(”
    1>g:codingffmpegffmpeg-20160413-git-0efafc5-win32-devincludelibavutilerror.h(110): error C2085: “av_make_error_string”: 不在形参表中
    1>g:codingffmpegffmpeg-20160413-git-0efafc5-win32-devincludelibavutilerror.h(110): error C2143: 语法错误 : 缺少“;”(在“{”的前面)
    1>g:codingffmpegffmpeg-20160413-git-0efafc5-win32-devincludelibavutilmem.h(93): error C2054: 在“inline”之后应输入“(”


    wikipedia解释:

    C++,C99和GNU C都支持内联函数,然而1989 ANSI C,这个最被广泛使用的C标准却不支持inline。


    解决方案是:在该头文件中加入

    #if defined(WIN32) && !defined(__cplusplus)
    #define inline __inline
    #endif


    或者直接写CPP程序

    #include <stdio.h>
    extern "C"
    {
    #include <libavformat/avformat.h>
    }
    
    int main(int argc, char **argv)
    {
    	AVFormatContext *fmt_ctx = NULL;
    	int ret;
    
    	av_register_all();
    	if ((ret = avformat_open_input(&fmt_ctx, "bad.mp4", NULL, NULL)))
    		return ret;
    
    
    	avformat_close_input(&fmt_ctx);
    	return 0;
    }
    



    Keep it simple!
    作者:N3verL4nd
    知识共享,欢迎转载。
  • 相关阅读:
    【cocos2d-js官方文档】十四、cc.spriteFrameCache 改造说明
    [SVN]创建本地的SVN仓库
    [C++]函数参数浅析
    [Windows Phone]AnimationHelper管理分散的Storyboard
    [Windows Phone]常用类库&API推荐
    [Windows Phone]模仿魔兽3技能按钮SkillButton
    [C++]引用浅析
    [C++]new和delete
    [C++]指针浅析
    [C++]C++中的运行时类型检测
  • 原文地址:https://www.cnblogs.com/lgh1992314/p/5834697.html
Copyright © 2011-2022 走看看