简体   繁体   中英

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:

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.

Move the line with the error underneath the typedef struct ... string_proc_key;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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