Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/134.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ typedef无效编译错误(已初始化(改用decltype))_C++_Compiler Errors - Fatal编程技术网

C++ typedef无效编译错误(已初始化(改用decltype))

C++ typedef无效编译错误(已初始化(改用decltype)),c++,compiler-errors,C++,Compiler Errors,我试图用一些structs编译一个简单的头文件,但我遇到了以下错误: ppal.h:25:34: error: typedef ‘string_proc_func’ is initialized (use decltype instead) typedef void (*string_proc_func)(string_proc_key*); 还有很多其他的错误,但我认为这一个是导致其他错误的原因。我的标题如下所示: #include <stdint.h> using namesp

我试图用一些
struct
s编译一个简单的头文件,但我遇到了以下错误:

ppal.h:25:34: error: typedef ‘string_proc_func’ is initialized (use decltype instead)
typedef void (*string_proc_func)(string_proc_key*);
还有很多其他的错误,但我认为这一个是导致其他错误的原因。我的标题如下所示:

#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;
#包括
使用名称空间std;
typedef结构字符串\u过程列表\u t
{
字符*名称;
首先是结构字符串\u proc\u节点\u t*;
结构字符串\u proc\u节点\u t*last;
}__属性__((_压缩__))字符串_进程列表;
typedef结构字符串\u过程\u节点\u t
{
struct string\u proc\u node\u t*next;
struct string\u proc\u node\u t*previous;
字符串程序函数f;
字符串处理函数;
字符串\u proc\u func\u类型;
}__属性__((_压缩__))字符串_过程_节点;
typedef void(*string_proc_func)(string_proc_key*);
typedef枚举字符串\u过程\u函数\u类型\u t
{
可逆=0,
不可逆=1
}_uuu属性_uuu((uuu压缩_uuu))字符串_u过程函数类型;
typedef结构字符串\u程序键\u t
{
uint32_t长度;
字符*值;
}__属性__((_压缩__))字符串_进程键;

我查找了类似的问题,但找不到如何解决此问题。

您试图在声明之前使用
string\u proc\u key


将带有错误的行移到
typedef结构下面。。。字符串进程键

您是否尝试过使用
decltype
,正如错误提示的那样?同样值得注意的是,您不应该在
typedef
后面隐藏指针间接指向的级别,因为这会使维护人员的生活更加困难。考虑<代码> TyPulf空格StrugPoPrimuFunc(StrugE-PrackKyK*);<代码>而不是。。。如果您要声明
string\u proc\u func x
,请改为声明
string\u proc\u func*x
。而且,在头文件中使用它会带来很多麻烦。我不确定decltype对指向函数的指针的工作方式是否与typedef相同?如果
\u attribute\u((\u packed\u))
按照名称所示,
char*value
是否会错位?目的何在?