C Function is deprecated

I used the code in the link below:

Readline Library

And I defined a structure like this

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;

When I compile the code, the compiler displays these warnings:

"Function deprecated [-Wdeprecated-declarations]"

So, what type should I change if I cannot use the type of the function?

+4
source share
2 answers

Functionis typedef(an alias of a pointer to a return function int) marked as an obsolete library

typedef int Function () __attribute__ ((deprecated));

Just use:

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;
+6
source

I think you should give up the function. And the following may work.

#include <stdio.h>

typedef void (*Function)();

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;

int main() {
    COMMAND commond;

    puts( "end" );



    return 0;
}
-3
source

Source: https://habr.com/ru/post/1676435/


All Articles