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
知识共享,欢迎转载。
原文地址:https://www.cnblogs.com/lgh1992314/p/5834697.html