好的,所以我想使用 gstreamer 库。
1。情况
我有一些代码:
#include <gst/gstpipeline.h>
#include <gst/gst.h>
...
GstElement* pipe = gst_pipeline_new("PipeName");
在哪里gst_pipeline_new
在 gstpipeline.h 中声明:
GstElement* gst_pipeline_new (const gchar* name) G_GNUC_MALLOC;
在系统某处定义了不明显的“事物”:):
typedef struct _GstElement GstElement; // gstelement.h
typedef char gchar; // gtypes.h
#define G_GNUC_MALLOC __attribute__((__malloc__)) // gmacros.h
2。问题
由于我使用 make 进行构建,因此在编译和链接期间没有出现任何错误。程序本身也运行正常。然而... 在 Eclipse IDE 中出现以下错误:
Description Resource Path Location Type
Invalid arguments '
Candidates are:
_GstElement * gst_pipeline_new(const ? *)
' file.cc /path/to/file line 106 Semantic Error
我将 Makefile 中指定的所有包含目录添加到 eclipse 项目配置(项目->属性->C/C++ 常规->路径和符号->包含->C++)。当然是C++项目。
3。问题
如何摆脱 Eclipse 错误?我不知道该怎么做……这让我很生气,因为现在我使用了一些遗留代码,并且我有大约 100 个这样的错误。
到目前为止我已经尝试过:
- 通过
reinterpret_cast<>()
选角或 C 类转换为const gchar*
- 添加
typedef char gchar
在文件的开头 - 在任何其他包含之前! - 包括
gtypes.h
(gchar
在那里定义)——也在任何其他包含之前 - 重新声明 `_GstElement gst_pipeline_new(const gchar* name)'
这些都没有帮助...
对我来说,Eclipse 似乎没有看到 gchar
输入,因为它说候选人是 _GstElement * gst_pipeline_new(const ? *)
在哪里?
替代真实类型。但我不知道如何制作(或事件力 :))Eclipse 来查看它...
最佳答案
很可能 eclipse 只是不知道您的包含路径(对于这个特定的库)并提示未索引的类型和声明。
您可以在“项目->属性->C++ 通用->路径和符号”下添加它们
如果这没有帮助,您还可以关闭语义错误检查(请参阅代码分析),无论是整体还是针对特定错误类型。
关于c++ - 使用 gstreamer 时出现 Eclipse 无效参数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20142337/