public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Sebastian Huber <sebastian-huber@web.de>
To: <gcc-help@gcc.gnu.org>
Subject: Re: Pointer to a function forbid!!
Date: Sat, 13 Apr 2002 18:00:00 -0000	[thread overview]
Message-ID: <E16wLX1-0005sj-00@smtp.web.de> (raw)
In-Reply-To: <00ce01c1e246$0cb10380$0300a8c0@yellow>

Hello,
you take the pointer of the A::f() function, this functions calls then your 
member function via the handed over this pointer. This approach works only if 
the code that calls the funktion via the pointer passes an arbitrary object 
via a void pointer to the function, in our special case the this pointer.
The declaration of such functions is should be similar to void* (*f)(void*), 
at least for a function executed in a POSIX thread. I don't know if your 
handler functions works the same way. If not you have to use a globel object 
and a wraper function.

On Friday 12 April 2002 19:18, you wrote:
> Thank you, but could you explain something to me ?  Is f the name of the
> function I'm needing a pointer to, or is it ADDED to the class?  I'm not
> quite sure how I use this.  Is m() the member function that I'm needing
> the pointer to? I know I replace the A with the name of my class, but
> I'm not sure which other items I'm supposed to substitute for.  Thanks a
> lot man.
>
> > -----Original Message-----
> > From: sebastian-huber@web.de [mailto:sebastian-huber@web.de]
> > Sent: Friday, April 12, 2002 11:59 AM
> > To: Glover George
> > Subject: Re: Pointer to a function forbid!!
> >
> >
> > Hello,
> > if you want to avoid global variables, you can try this:
> >
> > class A {
> > public:
> > 	static void f( void* thisPointer)
> > 	{
> > 		static_cast<A*>( thisPointer)->m();
> > 	}
> >
> > private:
> > 	void m();
> > };
> >
> > This works a least with the POSIX thread functions.
> >
> > [...]

  reply	other threads:[~2002-04-13 11:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E16w4Nu-0002jV-00@smtp.web.de>
2002-04-12 15:15 ` Glover George
2002-04-13 18:00   ` Sebastian Huber [this message]
2002-04-13 21:04     ` Segmentation fault!! Reggie Smith
2002-04-14  1:39       ` Ashish Gupta
     [not found] <616BE6A276E3714788D2AC35C40CD18D5B1F89@whale.softwire.co.uk>
2002-04-12  5:56 ` Pointer to a function forbid!! Rupert Wood
     [not found] <E16vjXV-0002Ty-00@smtp.web.de>
2002-04-11 12:59 ` Glover George
2002-04-12 10:18   ` Sebastian Huber
2002-04-11 11:32 Glover George

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E16wLX1-0005sj-00@smtp.web.de \
    --to=sebastian-huber@web.de \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).