C函数已弃用

Jas*_*uCC 5 c readline compiler-warnings

我使用了以下链接中的代码:

Readline库

我定义了这样的结构

typedef struct {
  char *name;           /* User printable name of the function. */
  Function *func;       /* Function to call to do the job. */
  char *doc;            /* Documentation for this function.  */
} COMMAND;
Run Code Online (Sandbox Code Playgroud)

编译代码时,编译器会显示以下警告:

"函数已弃用[-Wdeprecated-declarations]"

那么如果我不能使用函数类型,我应该改变什么类型?

Dav*_*eri 8

Functiontypedef(由函数返回指针的别名int)标记为已弃用:

typedef int Function () __attribute__ ((deprecated));
Run Code Online (Sandbox Code Playgroud)

只需使用:

typedef struct {
  char *name;            /* User printable name of the function. */
  int (*func)();         /* Function to call to do the job. */
  char *doc;             /* Documentation for this function.  */
} COMMAND;
Run Code Online (Sandbox Code Playgroud)