Read-only archive of the All About Symbian forum (2001–2013) · About this archive

global variables

1 replies · 2,081 views · Started 13 January 2003

I hope this is not an incredibly stupid question, but I'm asking it anyway: 😉

Is there a way to have global variables in a symbian c++ program? The compiler refuses to accept them, but without it, porting certain apps is quite a bit more complex... Most annoying thing about it is that I can't have static members in classes.

Any ideas?

There isn't any way to use standard global variables in a Symbian application (though they are allowed in EXEs). There are several ways round this:

1. Use thread-local storage to provide global data. Check out the Dll::Tls() and Dll::SetTls() functions.

2. Put your global data in an EXE which is started and controlled by your application.

3. If you're developing for the P800, you can use the third-party system ECompXL.