嗨,我正在使用 xcode 编译 ffmpeg,我相信它使用 clang 进行编译。在 ffmpeg 中有一个带有名为“class”的成员变量的结构,我相信这在 C 中非常好,但 clang 正试图将其解析为关键字。知道如何解决吗?基本上cpp文件中的以下内容会导致错误:
extern C {
typedef struct {
int class;
} SomeStruct;
}
它试图将类解释为关键字。
仅供参考,在 ffmpeg 中引发错误的文件是 libavcodec/mpegvideo.h,我需要包含它才能访问 MpegEncContext 结构以提取运动图信息。
编辑
上面的代码示例只是为了演示错误。但也许它可以通过另一种方式修复。在我的实际代码中,我有这样的:
#ifdef __cplusplus
extern "C" {
#endif
#include "libavcodec/mpegvideo.h"
#include "libavformat/avformat.h"
#if __cplusplus
} //Extern C
#endif
我如何才能将这两个文件包含为 C 文件而不是 C++?
谢谢