C 初始化类型时不兼容的类型
我不明白为什么会出现这个错误。也许有人看到了 这里是错误C 初始化类型时不兼容的类型,c,debugging,C,Debugging,我不明白为什么会出现这个错误。也许有人看到了 这里是错误 actor_plazma.c:92: error: incompatible types when initializing type ‘int (*)(struct VisObject *)’ using type ‘float’ actor_plazma.c:92: error: incompatible types when initializing type ‘void *’ using type ‘float’ make: **
actor_plazma.c:92: error: incompatible types when initializing type ‘int (*)(struct VisObject *)’ using type ‘float’
actor_plazma.c:92: error: incompatible types when initializing type ‘void *’ using type ‘float’
make: *** [actor_plazma.lo] Error 1
这是相关代码
#define VISUAL_PARAM_LIST_ENTRY_FLOAT(name, val, lim) { name, VISUAL_PARAM_ENTRY_TYPE_FLOAT, 0, val, lim }
#define VISUAL_PARAM_LIMIT_FLOAT(min, max) { VISUAL_PARAM_ENTRY_LIMIT_TYPE_FLOAT, 0, min, 0, 0, max, 0 }
typedef enum {
VISUAL_PARAM_ENTRY_LIMIT_TYPE_NULL,
VISUAL_PARAM_ENTRY_LIMIT_TYPE_INTEGER,
VISUAL_PARAM_ENTRY_LIMIT_TYPE_FLOAT,
VISUAL_PARAM_ENTRY_LIMIT_TYPE_DOUBLE,
VISUAL_PARAM_ENTRY_LIMIT_TYPE_END
} VisParamEntryLimitType;
static VisParamEntryProxy params[] = {
VISUAL_PARAM_LIST_ENTRY_INTEGER ("bass sensitivity", 0, VISUAL_PARAM_LIMIT_NONE),
VISUAL_PARAM_LIST_ENTRY_INTEGER ("plazma effect", TRUE, VISUAL_PARAM_LIMIT_BOOLEAN),
VISUAL_PARAM_LIST_ENTRY_INTEGER ("3d effect option", FALSE, VISUAL_PARAM_LIMIT_BOOLEAN),
VISUAL_PARAM_LIST_ENTRY_INTEGER ("lines", TRUE, VISUAL_PARAM_LIMIT_BOOLEAN),
VISUAL_PARAM_LIST_ENTRY_INTEGER ("spectrum", TRUE, VISUAL_PARAM_LIMIT_BOOLEAN),
VISUAL_PARAM_LIST_ENTRY_INTEGER ("3d effect", TRUE, VISUAL_PARAM_LIMIT_BOOLEAN),
VISUAL_PARAM_LIST_ENTRY_FLOAT ("rotation speed", 0.4, VISUAL_PARAM_LIMIT_FLOAT(0.0f, 1000.0f)), // line 92
VISUAL_PARAM_LIST_END
};
编辑:哦,没有包括所有内容:
typedef enum {
VISUAL_PARAM_ENTRY_TYPE_NULL, /**< No parameter. */
VISUAL_PARAM_ENTRY_TYPE_STRING, /**< String parameter. */
VISUAL_PARAM_ENTRY_TYPE_INTEGER, /**< Integer parameter. */
VISUAL_PARAM_ENTRY_TYPE_FLOAT, /**< Floating point parameter. */
VISUAL_PARAM_ENTRY_TYPE_DOUBLE, /**< Double floating point parameter. */
VISUAL_PARAM_ENTRY_TYPE_COLOR, /**< VisColor parameter. */
VISUAL_PARAM_ENTRY_TYPE_PALETTE, /**< VisPalette parameter. */
VISUAL_PARAM_ENTRY_TYPE_OBJECT, /**< VisObject parameter. */
VISUAL_PARAM_ENTRY_TYPE_END /**< List end, and used as terminator for VisParamEntry lists. */
} VisParamEntryType;
typedef enum {
VISUAL_PARAM_ENTRY_LIMIT_TYPE_NULL,
VISUAL_PARAM_ENTRY_LIMIT_TYPE_INTEGER,
VISUAL_PARAM_ENTRY_LIMIT_TYPE_FLOAT,
VISUAL_PARAM_ENTRY_LIMIT_TYPE_DOUBLE,
VISUAL_PARAM_ENTRY_LIMIT_TYPE_END
} VisParamEntryLimitType;
struct _VisParamEntryLimitProxy {
VisParamEntryLimitType type;
struct {
int integer; /**< Integer data. */
float floating; /**< Floating point data. */
double doubleflt; /**< Double floating point data. */
} min;
struct {
int integer; /**< Integer data. */
float floating; /**< Floating point data. */
double doubleflt; /**< Double floating point data. */
} max;
};
struct _VisParamEntryProxy {
const char *name;
VisParamEntryType type;
char *string;
double value;
VisColor color;
VisParamEntryLimitProxy limit;
};
typedef枚举{
视觉参数输入类型为空,/**<无参数*/
视觉参数输入类型字符串,/**
类型VisParamEntryProxy
没有定义。但是,假设这里是一个转录错误,我认为错误是由于宏只提供了5或6个初始值设定项,而结构需要7个
或者,如果我弄错了类型链,那么它只需要6个值。对于后者,您有以下内容:
#define VISUAL_PARAM_LIST_ENTRY_FLOAT(name, val, lim) { name, VISUAL_PARAM_ENTRY_TYPE_FLOAT, 0, val, lim }
但我认为应该是这样的
#define VISUAL_PARAM_LIST_ENTRY_FLOAT(name, val, lim) { name, VISUAL_PARAM_ENTRY_TYPE_FLOAT, 0, val, SOMECOLOR, lim}
提供VisParamEntryProxy和VisParamentryMittype结构的定义什么是VisParamEntryProxy?让编译器生成预处理的输出。然后你应该能够更清楚地知道在疯狂的宏替换之后发生了什么。是的,颜色是个问题。我把它移到最后一个位置,现在它可以工作了。谢谢