[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++ compiling problems
> From: Jan-Peter Nilsson <email@example.com>
> Date: Tue, 26 Jun 2001 10:02:46 +0200
> When I use a class as the one include below in this text the instance
> MyClassInstance is NOT created when the program is started.
> It is possible to create new instances while the program is running but the
> static instance is for some reason not created.
> The code works perfectly on a linux machine with gcc compiling but not on
> etrax with cris-gcc.
I believe this is because you're using uclibc and that the
uclibc startup code doesn't handle initialization code
responsible for global object construction correctly.
The good news is that this should (and seems to) just work with
glibc for the upcoming release. If I add a ";" after the
closing "}" at the end of the "class MyClass" declaration ;-)
and add this code at the end of MyClass.cpp:
int main ()
<< "Var1: " << MyClassInstance.MyFunction1()
<< " Var2: " << MyClassInstance.MyFunction2()
<< "xVar1: " << x.MyFunction1()
<< " xVar2: " << x.MyFunction2()
and then compile with "g++-cris -O2 -mlinux -o my MyClass.cpp",
with the not-yet-released cris-dist-1.13, then I get this
Var1: 3 Var2: 7
xVar1: 3 xVar2: 7