Make a global variable private
4 posters
Make a global variable private
Hi,
I'm modifying one of the tutorials, and trying to use two similar (duplicated the files, but they're different) copies of template.mm/template.h. Although I'd like to keep the variables declared at the top named the same, this is causing a linking error.
Basically I'm looking for a way to make them private, but just doing
"private bool startGame" causes an error.
I know this isn't specifically an sio2 problem but any help would be greatly appreciated!
I'm modifying one of the tutorials, and trying to use two similar (duplicated the files, but they're different) copies of template.mm/template.h. Although I'd like to keep the variables declared at the top named the same, this is causing a linking error.
Basically I'm looking for a way to make them private, but just doing
"private bool startGame" causes an error.
I know this isn't specifically an sio2 problem but any help would be greatly appreciated!
Smittens- Posts : 1
Join date : 2009-02-11
Re: Make a global variable private
There is no such thing as private in C. You need to use C++ to get private vars. You can use the static keyword inside a block to make the variable only available in that block but from the sounds of it you just need to rename one of the vars.
uprise78- Posts : 228
Join date : 2008-10-31
Re: Make a global variable private
You can use all of the C++ techniques for compartmentalization, including namespaces, and 'extern'.
Best,
-joshua
Best,
-joshua
meteors- Posts : 241
Join date : 2008-11-08
Location : Sunny Florida
Re: Make a global variable private
I don't know exactly what you want but if you want a variable to only be accessed from one file you can put it in the .c file like this:
- Code:
#include "../src/sio2/sio2.h"
int something;
bool smoethingmore;
oioioi- Posts : 136
Join date : 2008-12-02
Location : Norway
Similar topics
» Best Practice for an Object with Variable Material Properties
» Rotate object through global axis
» how to make a new game
» particles to make a candle flame
» accelerometer (How can I make them work just the oposite?)
» Rotate object through global axis
» how to make a new game
» particles to make a candle flame
» accelerometer (How can I make them work just the oposite?)
Permissions in this forum:
You cannot reply to topics in this forum