1.理清一个概念:
windows x86指32位cpu
windows x64指64位cpu
2.如下代码:
#include <iostream>
//要引用C语言函数
extern "C"
{
#include <libavcodec/avcodec.h>
}
//预处理指令来导入库
#pragma comment(lib,"avcodec.lib")
using namespace std;
int main(int argc,char *argv[])
{
//显示ffmpeg编译配置信息
cout << "test FFmpeg.club" << endl;
#ifdef _WIN64 //64位
cout << "windows x64" << endl;
#endif
#ifdef WIN32 //32位
cout << "windows x86" << endl;
#endif
#ifdef _WIN32 //32位和64位
#else
cout << "linux system operation" << endl;
#endif
cout << avcodec_configuration() << endl;
getchar();
return 0;
}
分析:WIN32宏指的是,32
而_WIN32指的是32位和64位。所以这个宏主要用于区分windows和linux连个操作系统。