Re: functions calls Vs calls using function pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Digvijoy Chatterjee writes:
 > In 5/25/06, Andrew Haley <aph@xxxxxxxxxx> 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.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux