This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to pass function names as parameter?


I want to pass function names as parameter to a subroutine.
I made a simple test programm:
-------------------
/* */
#include <stdio.h>


main ()
{
 int feins ();
 int fzwei ();
 int rufen ();
  
  rufen ( feins () );

  rufen ( fzwei () );
}

rufen ( der )
int (*der) ();
{
   (*der) ();
}

feins () 
{
  printf ("\nThat is module eins\n\n");
}

fzwei ()
{
  printf ("\nThat is module zwei\n\n");
}
---------------------
The program compiles and links successfully.
But running the program gives an error. the first call 'rufen( feins () )' 
calls the
correct function 'feins' and the message there. But then I get 'message access 
error'
(as I would translate it).
 
What could be wrong?

Any hint is appreciated.

Walter


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]