Threads & Global funcs 
Author Message
 Threads & Global funcs

Newbie question here,
I need to access a class function from a global function. So far the
global func doesn't see the Class that I want to access in my project.
What I'm trying to do is have a "global" thread controlling func be able
to post a msg to the View.
Appreciate any help!
Bradj


Sun, 26 Oct 2003 22:28:22 GMT  
 Threads & Global funcs

            Add a 'this' pointer which points to your Class; as a parameter
to your global function.
            Now from inside your global function call the class function.

            Something like..

                            BOOL gfMyGlobalFunc ( CMyClass *pMyClass )
                            {
                                 if ( pMyClass  )
                                    return pMyClass->MyClassFunction();
                            }

Cheers
Check Abdoul
-------------------


Quote:
> Newbie question here,
> I need to access a class function from a global function. So far the
> global func doesn't see the Class that I want to access in my project.
> What I'm trying to do is have a "global" thread controlling func be able
> to post a msg to the View.
> Appreciate any help!
> Bradj



Sun, 26 Oct 2003 22:44:43 GMT  
 Threads & Global funcs
Thanks for the reply,
I tried this but the trouble is that the global func doesn't see "CMyClass" and
dies while compiling witha ----> 'CMyClass' :  undeclared identifier.
Quote:

>             Add a 'this' pointer which points to your Class; as a parameter
> to your global function.
>             Now from inside your global function call the class function.

>             Something like..

>                             BOOL gfMyGlobalFunc ( CMyClass *pMyClass )
>                             {
>                                  if ( pMyClass  )
>                                     return pMyClass->MyClassFunction();
>                             }

> Cheers
> Check Abdoul
> -------------------



> > Newbie question here,
> > I need to access a class function from a global function. So far the
> > global func doesn't see the Class that I want to access in my project.
> > What I'm trying to do is have a "global" thread controlling func be able
> > to post a msg to the View.
> > Appreciate any help!
> > Bradj



Sun, 26 Oct 2003 23:42:16 GMT  
 Threads & Global funcs
You have to add your class header { ex:- MyClass.h }  to the file where your
global function is declared.

Cheers
Check Abdoul
------------------


Quote:
> Thanks for the reply,
> I tried this but the trouble is that the global func doesn't see
"CMyClass" and
> dies while compiling witha ----> 'CMyClass' :  undeclared identifier.


> >             Add a 'this' pointer which points to your Class; as a
parameter
> > to your global function.
> >             Now from inside your global function call the class
function.

> >             Something like..

> >                             BOOL gfMyGlobalFunc ( CMyClass *pMyClass )
> >                             {
> >                                  if ( pMyClass  )
> >                                     return pMyClass->MyClassFunction();
> >                             }

> > Cheers
> > Check Abdoul
> > -------------------



> > > Newbie question here,
> > > I need to access a class function from a global function. So far the
> > > global func doesn't see the Class that I want to access in my project.
> > > What I'm trying to do is have a "global" thread controlling func be
able
> > > to post a msg to the View.
> > > Appreciate any help!
> > > Bradj



Mon, 27 Oct 2003 00:02:01 GMT  
 Threads & Global funcs
Yep, I tried that also, all I got were a bunch of compiler errors relating
undeclared identifiers and subsequent missing storage-class or type identifiers.
I also tried declaring a global var in theApp and my global funcs still couldn't
see it. By the way, the Class in question is my app's View.
Thanks
Bradj
Quote:

> You have to add your class header { ex:- MyClass.h }  to the file where your
> global function is declared.

> Cheers
> Check Abdoul
> ------------------



> > Thanks for the reply,
> > I tried this but the trouble is that the global func doesn't see
> "CMyClass" and
> > dies while compiling witha ----> 'CMyClass' :  undeclared identifier.


> > >             Add a 'this' pointer which points to your Class; as a
> parameter
> > > to your global function.
> > >             Now from inside your global function call the class
> function.

> > >             Something like..

> > >                             BOOL gfMyGlobalFunc ( CMyClass *pMyClass )
> > >                             {
> > >                                  if ( pMyClass  )
> > >                                     return pMyClass->MyClassFunction();
> > >                             }

> > > Cheers
> > > Check Abdoul
> > > -------------------



> > > > Newbie question here,
> > > > I need to access a class function from a global function. So far the
> > > > global func doesn't see the Class that I want to access in my project.
> > > > What I'm trying to do is have a "global" thread controlling func be
> able
> > > > to post a msg to the View.
> > > > Appreciate any help!
> > > > Bradj



Mon, 27 Oct 2003 02:43:58 GMT  
 Threads & Global funcs
Doh! It seems that I had a few dependencies unaccounted for when I included my Class
header. Things are working much better now.
Thanks for all the help!
Bradj
Quote:

> Yep, I tried that also, all I got were a bunch of compiler errors relating
> undeclared identifiers and subsequent missing storage-class or type identifiers.
> I also tried declaring a global var in theApp and my global funcs still couldn't
> see it. By the way, the Class in question is my app's View.
> Thanks
> Bradj


> > You have to add your class header { ex:- MyClass.h }  to the file where your
> > global function is declared.

> > Cheers
> > Check Abdoul
> > ------------------



> > > Thanks for the reply,
> > > I tried this but the trouble is that the global func doesn't see
> > "CMyClass" and
> > > dies while compiling witha ----> 'CMyClass' :  undeclared identifier.


> > > >             Add a 'this' pointer which points to your Class; as a
> > parameter
> > > > to your global function.
> > > >             Now from inside your global function call the class
> > function.

> > > >             Something like..

> > > >                             BOOL gfMyGlobalFunc ( CMyClass *pMyClass )
> > > >                             {
> > > >                                  if ( pMyClass  )
> > > >                                     return pMyClass->MyClassFunction();
> > > >                             }

> > > > Cheers
> > > > Check Abdoul
> > > > -------------------



> > > > > Newbie question here,
> > > > > I need to access a class function from a global function. So far the
> > > > > global func doesn't see the Class that I want to access in my project.
> > > > > What I'm trying to do is have a "global" thread controlling func be
> > able
> > > > > to post a msg to the View.
> > > > > Appreciate any help!
> > > > > Bradj



Mon, 27 Oct 2003 04:33:07 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Global funcs & Threads

2. Global funcs & Threads

3. Worker thread funcs...where?

4. Client Server && Threads

5. Interprocess Communication && Multiple threads of execution

6. Global variable access from multiple threads.

7. global variables thread-safe

8. More than one global threading model defined

9. global variable error in commucation between threads ;)

10. Global variables and threads

11. Thread question using global function

12. CreateThread and worker threads using global function

 

 
Powered by phpBB® Forum Software