1
struct ast_channel *(* const requester)(const char *type, int format, void *data, int *cause);

What is the meaning of this line?

Second question: what is the advantage of using

static struct hello
{
    int a;
    chat b;
};

over simply

struct hello
{
    int a;
};

Also, what is the difference between static char p[] and char p[];?

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
lipune
  • 19
  • 2

5 Answers5

5

My C is a little rusty: requester is a constant pointer to a function returning a pointer to a ast_channel struct.

See these articles:

What the static keyword means is dependent on where the declaration appears in code. Inside a function it indicates that the variable should not be put on the stack but in the data segment and is persistent when the function goes out of scope (i.e. is not running). Outside a function it indicates that the variable is not accessable outside the file it is in.

Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
4

Teaching to fish (instead of giving the fish):

Reading C type declarations

What does static mean in a C program

Community
  • 1
  • 1
Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
1

The first is a declaration (as well as definition) of a constant pointer to function which returns pointer to struct ast_channel and accepts parameters listed in the last pair of parantheses. This function pointer is named requester.

The meaning of static is actually dependent on the context. However it has been explained in previous answers.

dragonfly
  • 1,590
  • 10
  • 14
0

The first line is a function pointer, of the type ast_channnel. More of the code would need to be provided to adequately explain its use. Was that defined inside of a structure? If so, it would be entered via structname->requester( ... args ... ).

This tutorial might help you make sense of that. Links have already been provided by others to find out what 'static' implies.

Tim Post
  • 33,371
  • 15
  • 110
  • 174
0

cdecl.org is your friend here:

struct ast_channel *(* const requester)(const char *, int , void *, int *) - declare requester as const pointer to function (pointer to const char, int, pointer to void, pointer to int) returning pointer to struct ast_channel
Nikolai Fetissov
  • 82,306
  • 11
  • 110
  • 171