1 msgRe: C++ auto_ptr template query solved
2 msgISO C++
3 msgLD_LIBRARY_PATH needed for gcc-3.4.5 executable
2 msgmark.urs
3 msgproblem with catalog()
2 msgAMD64 ABI and comparison of structures
1 msguse of changes in STL library

functions calls Vs calls using function pointers
\ Digvijoy Chatterjee (24 May 2006)
. \ Andrew Haley (25 May 2006)
. . \ Digvijoy Chatterjee (25 May 2006)
. . . \ Andrew Haley (25 May 2006)
. \ Digvijoy Chatterjee (25 May 2006)
. . \ Andrew Haley (25 May 2006)

1 msghave the experience but no degree, we can help
1 msgGenerate listing files
1 msgRelinking GCC as Static?
1 msgHow can compiled file include preprocessor macr...
1 msgwhat should we do next step.
2 msgC++ auto_ptr template query
3 msgARM Inline Assembler and 64 bit variables
7 msgLinking un-referenced function
6 msgCurious segmentation fault...
3 msgproblem passing constants to inline asm
1 msg[Platform specific] About data segment
3 msgOpenSource alternative to Purify memory debugger??
Subject:Re: functions calls Vs calls using function pointers
Group:Gcc-help
From:Andrew Haley
Date:25 May 2006


Digvijoy Chatterjee writes:
> In 5/25/06, Andrew Haley <aph> wrote:
> >
> > You declare fp to be type void (*fptr) (int).
> >
> > Therefore if you call a function through fp, you have to pass an int.
> > This is because of the type of variable fp, not because of A.
> >
> > You can easily demonstrate this by compiling:
> >
> > typedef void (*fptr) (int);
> >
> > int main()
> > {
> > fptr fp;
> > fp();
> > }
> >
> > > I want the name of the function where the compiler while parsing a .c
> > > file associates a function pointer ,to the function which will be
> > > called at runtime.
> >
> > This never happens, and therefore I can't answer your question.
> >
> > Andrew.
> >
> Right ,
> Which is the file then which has code , to compare the erroneous call
> fp(); to its declaration as in the typedef

Look at convert_arguments in c-typeck.c.

> ?where does the compiler know fp() is a function call ?

case CPP_OPEN_PAREN:
/* Function call. */
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
exprlist = NULL_TREE;
else
exprlist = c_parser_expr_list (parser, true);
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
expr.value = build_function_call (expr.value, exprlist);
expr.original_code = ERROR_MARK;
break;


in c-parser.c.

Andrew.


© 2004-2008 readlist.com