Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: sharing var...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 7 Topic 45771 of 47032
Post > Topic >>

Re: sharing variables across mulitple files

by dizzy <dizzy@[EMAIL PROTECTED] > May 7, 2008 at 11:39 AM

Jim Langston wrote:

> I have one project where I am forces to use global variables because of
> the engine I am using having multiple callbbacks and it's impossible for
> me to
> pass the data.  One thing I did was I put all the global variables in a
> structure and have just one instance of the structure.  I'm not sure if
it
> simplifies anything, but it helps.

Sounds like a very bad C callback mechanism. It is a "C" callback
mechanism
because otherwise it would have allowed generic functors and full compile
time type checking on the given functions and arguments. It is a "bad C
callback mechanism" because otherwise it would take in one form or another
an opaque argument (usually under the form of a "void*" argument) to
register along with the callback and that value is passed back to the
callback, the argument usually being used to transmit state from the code
registering the callback to the callback.

Yeah, organizing the data to be shared in a struct may help (it is usually
required with the "void*" passing method described above).

-- 
Dizzy
 




 7 Posts in Topic:
sharing variables across mulitple files
"awhan.iitk@[EMAIL P  2008-05-06 02:58:33 
Re: sharing variables across mulitple files
"Jim Langston"   2008-05-06 03:07:00 
Re: sharing variables across mulitple files
"awhan.iitk@[EMAIL P  2008-05-06 03:26:32 
Re: sharing variables across mulitple files
Pete Becker <pete@[EMA  2008-05-06 07:00:45 
Re: sharing variables across mulitple files
"Jim Langston"   2008-05-06 05:50:14 
Re: sharing variables across mulitple files
dizzy <dizzy@[EMAIL PR  2008-05-07 11:39:30 
Re: sharing variables across mulitple files
Cynic <nik.n.nair@[EMA  2008-05-06 19:26:22 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 21:10:11 CDT 2008.