R
RocTheEngy
Greetings c.l.c...
I am trying to understand some structure definitions in working code
(e.g. compiles, runs & produces expected results) that I have. I
think I've trimmed the code to what is relevant to my question...
Which is: What is the (*vector) in the "struct function" declaration.
What is that line doing?
My best guess is that it is a function definition that returns a struct
variable * and takes two paramters; an int (argc) and a pointer to a
struct variable (argv). I'm not quite sure what the (*vector) is ...
other than the pointer to the function itself?
Is that the name of the struct [function] member, because I see code
like fnc_start.vector = null; later in the progam... but i never see it
assigned to a "real" function address (for fnc_start and fnc_end,
anyhow) - So I'm skeptical of my understanding...
Any insight/explaination would be greatly appreciated. Thanks.
#define MAXVARNAMESIZE 32
struct variable
{
char name[ MAXVARNAMESIZE + 1 ];
int type;
char *array;
size_t array_units;
struct variable *next;
};
struct function
{
char name[ MAXVARNAMESIZE + 1 ];
int arguments;
int type;
struct variable * (*vector) ( int argc, struct variable *argv ); /*
function pointer ? */
struct function *next;
};
extern struct function fnc_start, fnc_end;
I am trying to understand some structure definitions in working code
(e.g. compiles, runs & produces expected results) that I have. I
think I've trimmed the code to what is relevant to my question...
Which is: What is the (*vector) in the "struct function" declaration.
What is that line doing?
My best guess is that it is a function definition that returns a struct
variable * and takes two paramters; an int (argc) and a pointer to a
struct variable (argv). I'm not quite sure what the (*vector) is ...
other than the pointer to the function itself?
Is that the name of the struct [function] member, because I see code
like fnc_start.vector = null; later in the progam... but i never see it
assigned to a "real" function address (for fnc_start and fnc_end,
anyhow) - So I'm skeptical of my understanding...
Any insight/explaination would be greatly appreciated. Thanks.
#define MAXVARNAMESIZE 32
struct variable
{
char name[ MAXVARNAMESIZE + 1 ];
int type;
char *array;
size_t array_units;
struct variable *next;
};
struct function
{
char name[ MAXVARNAMESIZE + 1 ];
int arguments;
int type;
struct variable * (*vector) ( int argc, struct variable *argv ); /*
function pointer ? */
struct function *next;
};
extern struct function fnc_start, fnc_end;