public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* How to pass function names as parameter?
@ 2007-02-28 18:14 Walter Kasberg
  2007-02-28 21:31 ` John Love-Jensen
  0 siblings, 1 reply; 4+ messages in thread
From: Walter Kasberg @ 2007-02-28 18:14 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to pass function names as parameter?
  2007-02-28 18:14 How to pass function names as parameter? Walter Kasberg
@ 2007-02-28 21:31 ` John Love-Jensen
  2007-03-01  8:20   ` Walter Kasberg
  2007-03-01  8:28   ` Walter Kasberg
  0 siblings, 2 replies; 4+ messages in thread
From: John Love-Jensen @ 2007-02-28 21:31 UTC (permalink / raw)
  To: Walter Kasberg, MSX to GCC

Hi Walter,

This isn't doing what you think it is doing:

 rufen ( feins () );
 rufen ( fzwei () );

You probably wanted:

 rufen ( feins );
 rufen ( fzwei );

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to pass function names as parameter?
  2007-02-28 21:31 ` John Love-Jensen
@ 2007-03-01  8:20   ` Walter Kasberg
  2007-03-01  8:28   ` Walter Kasberg
  1 sibling, 0 replies; 4+ messages in thread
From: Walter Kasberg @ 2007-03-01  8:20 UTC (permalink / raw)
  To: John Love-Jensen; +Cc: MSX to GCC

On Wednesday 28 February 2007 19:48, John Love-Jensen wrote:
> Hi Walter,
>
> This isn't doing what you think it is doing:
>
>  rufen ( feins () );
>  rufen ( fzwei () );
>
> You probably wanted:
>
>  rufen ( feins );
>  rufen ( fzwei );
>
> HTH,
> --Eljay
I tried it, but it too does not work. There is still the memory address error.

Walter

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to pass function names as parameter?
  2007-02-28 21:31 ` John Love-Jensen
  2007-03-01  8:20   ` Walter Kasberg
@ 2007-03-01  8:28   ` Walter Kasberg
  1 sibling, 0 replies; 4+ messages in thread
From: Walter Kasberg @ 2007-03-01  8:28 UTC (permalink / raw)
  To: John Love-Jensen; +Cc: MSX to GCC

On Wednesday 28 February 2007 19:48, John Love-Jensen wrote:
> Hi Walter,
>
> This isn't doing what you think it is doing:
>
>  rufen ( feins () );
>  rufen ( fzwei () );
>
> You probably wanted:
>
>  rufen ( feins );
>  rufen ( fzwei );
>
> HTH,
> --Eljay
sorry, discard my previous mail.
I made a mistake: I changed the code but did not save the changes and compiled 
the old version.
Thanks, you are right, now it works.

Walter

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-03-01  8:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-28 18:14 How to pass function names as parameter? Walter Kasberg
2007-02-28 21:31 ` John Love-Jensen
2007-03-01  8:20   ` Walter Kasberg
2007-03-01  8:28   ` Walter Kasberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).