简体   繁体   English

typedef void编译错误(已初始化(请改用decltype))

[英]typedef void compilation error (is initialized (use decltype instead))

I'm trying to compile a simple header with some struct s but I'm getting this error: 我正在尝试使用一些struct编译一个简单的标头,但出现此错误:

ppal.h:25:34: error: typedef ‘string_proc_func’ is initialized (use decltype instead)
typedef void (*string_proc_func)(string_proc_key*);

There are a bunch of other errors but I think this one is the one causing the others. 还有很多其他错误,但我认为这是一个导致其他错误的错误。 My header looks like this: 我的标题看起来像这样:

#include <stdint.h>
using namespace std;

typedef struct string_proc_list_t
{
    char* name;
    struct string_proc_node_t* first;
    struct string_proc_node_t* last;
} __attribute__((__packed__)) string_proc_list;


typedef struct string_proc_node_t
{
    struct string_proc_node_t* next;
    struct string_proc_node_t* previous;
    string_proc_func f;
    string_proc_func g;
    string_proc_func_type type;
} __attribute__((__packed__)) string_proc_node;

typedef void (*string_proc_func)(string_proc_key*);

typedef enum string_proc_func_type_t
{
    REVERSIBLE = 0,
    IRREVERSIBLE = 1
} __attribute__((__packed__)) string_proc_func_type;

typedef struct string_proc_key_t
{
    uint32_t length;
    char* value;
} __attribute__((__packed__)) string_proc_key;

I looked for similar questions but I can't find how to fix this. 我寻找了类似的问题,但找不到解决方法。

You are trying to use string_proc_key before its declaration. 您正在尝试在声明string_proc_key之前使用它。

Move the line with the error underneath the typedef struct ... string_proc_key; 将错误所在的行typedef struct ... string_proc_key;下面typedef struct ... string_proc_key;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM