-2

B.A.T.M.A.N./A.L.F.R.E.D. OpenMesh project:

function read_answer instantiates a pointer to a type struct vis_print_ops that is defined

struct vis_print_ops
{
    void (*preamble)(void);
    void (*interfaces)(uint8_t iface_n, struct vis_iface *ifaces);
    void (*entries)(uint8_t entries_n, struct vis_entry *vis_entries,
            uint8_t iface_n, struct vis_iface *ifaces);
    void (*postamble)(void);
};

Now look at

void (*preamble)(void)

could you please tell me what is the meaning of the last (void)? Isn't

void (*preamble)

enough?

Cœur
  • 34,719
  • 24
  • 185
  • 251
Germano Massullo
  • 2,502
  • 10
  • 39
  • 55

2 Answers2

5

The last void means that there are no arguments in function that will be pointed by preamble.

void (*preamble) isn't enough because this is only a pointer to void whereas void (*preamble)(void) is a function pointer.

MikeCAT
  • 69,090
  • 10
  • 44
  • 65
5

It means that your declaring a function pointer with no parameters. It's not more complicated than that. It is similiar to something like: int main(void) and int main()

Both are the same. Be careful though as discussed in the comments, if you declare a function pointer without the void keyword and only the empty brackets it specifies a function pointer with undefined arguments.

Linus
  • 1,506
  • 16
  • 35