By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

too much globals?

P: n/a
Hi,

I have a program that runs perfectly under win32. But under WinCE it
fails to start (of course compiled for WinCE). It doesn't even reach
the winmain. So far OT, but the problem is - the only difference is
the number of functions and global variables I added to a version that
runs perfectly on both. Although some variables (in both cases) are
classes that have constructors (which are evaluated before main,
right?). Is there any limit of global variables? How can I avoid this
problem - or better: How can I check where it comes from?
My string class e.g. has:
class MyString
{
public:
char data[512];
}

And I have a lot of them...
Thank you in advice.
--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}

________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com
Jul 22 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Wed, 4 Aug 2004 08:53:20 +0200, Gernot Frisch <Me@Privacy.net> wrote:
Hi,

I have a program that runs perfectly under win32. But under WinCE it
fails to start (of course compiled for WinCE). It doesn't even reach
the winmain. So far OT, but the problem is - the only difference is
the number of functions and global variables I added to a version that
runs perfectly on both. Although some variables (in both cases) are
classes that have constructors (which are evaluated before main,
right?). Is there any limit of global variables? How can I avoid this
problem - or better: How can I check where it comes from?
My string class e.g. has:
class MyString
{
public:
char data[512];
}

And I have a lot of them...
Thank you in advice.


It seems quite likely you run into the "static initialization order
fiasco" (Marshall Cline's words not mine). Check the FAQ question #10.11
and following.

http://www.parashift.com/c++-faq-lit...html#faq-10.11

But if that doesn't sound like it then yes maybe you have hit some limit
on the size of global variables, but any such limit would be imposed by
your compiler and operating system not by C++.

I'd bet on the former however.

john
Jul 22 '05 #2

P: n/a
>
It seems quite likely you run into the "static initialization order
fiasco" (Marshall Cline's words not mine). Check the FAQ question #10.11
and following.

http://www.parashift.com/c++-faq-lit...html#faq-10.11

john


Reading the FAQ for myself I'm not sure it emphasises sufficiently that
one way to avoid initialisation order problems is to put all your global
variables in a single source file. That way the order of initialisation is
defined, its the same as the order that the globals occur in the file.

john
Jul 22 '05 #3

P: n/a
"Gernot Frisch" <Me@Privacy.net> tried to express:
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}

no return value? and in a group devoted to proper c++ usage? shame!
Jul 22 '05 #4

P: n/a
> no return value? and in a group devoted to proper c++ usage?
shame!

Doh! Sorry. I'll fix that. Thank you.
Jul 22 '05 #5

P: n/a

"Gernot Frisch" <Me@Privacy.net> wrote in message
news:2n************@uni-berlin.de...
no return value? and in a group devoted to proper c++ usage?

shame!

Doh! Sorry. I'll fix that. Thank you.


No don't. Strangely the C++ standard does not require a return value from
main.

john
Jul 22 '05 #6

P: n/a
> > > no return value? and in a group devoted to proper c++ usage?
shame!

Doh! Sorry. I'll fix that. Thank you.

No don't. Strangely the C++ standard does not require a return value

from main.


Oh...er... Yes, that was exaclty what I wanted to say - "learn the
standard before you flame me - you yaddayadda" ;)
Jul 22 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.