c++ - 如果 extern "C"包含与 Qt 库冲突怎么办?

标签 c++ qt namespaces ffmpeg extern

就我而言,我正在尝试使用 QtMultimedia 和 libffmpeg 作为解码器。
将 ffmpeg 导入为 extern "C",但 ffmpeg 的 AVPixelFormat 与 QVideoFrame 的 PixelFormat 冲突。

确切的错误:

'AVPixelFormat' : is not a member of 'QVideoFrame'



有谁知道可能的解决方案?

编辑:代码部分。

第 1 部分:Qt VideoWidget Sample

第 2 部分:libffmpeg 的使用,基于 dranger tutorial
extern "C"
{
    #include <libavcodec/avcodec.h>
    #include <libavformat/avformat.h>
    #include <libswscale/swscale.h>
}

最佳答案

这是由 FFmpeg 的 pixfmt.h 中的以下行引起的。 :
#define PixelFormat AVPixelFormat
您可以尝试以下技巧:

extern "C"
{
    #include <libavcodec/avcodec.h>
    #include <libavformat/avformat.h>
    #include <libswscale/swscale.h>
}

#undef PixelFormat
#include <qt headers>

关于c++ - 如果 extern "C"包含与 Qt 库冲突怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21854469/

相关文章:

c++ - 存储在 vector 中的图像都是相同的

c++ - 在项目中使用 QT 单元测试 - 冲突的 main(...) 函数

XML::LibXML 和命名空间

c++ - 命名空间的类析构函数

javascript - 在 JavaScript 中创建命名空间

c++ - XmlHttpRequest 错误?

c++ - C++ 中的简单代码在 Linux 中编译但不执行

qt - .exe无法通过QtCreator和Qt 4.8.1的外部运行。关于dll的问题

c++ - Qt-GUI有几个 "pages",如何同步几个QWidgets的大小

c++ - 标准是否指定源文件需要如何编译以及额外的预处理步骤是否是非标准的?