bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Static Variable


From: to_
Subject: Static Variable
Date: Sat, 6 Sep 2008 04:49:45 -0700 (PDT)
User-agent: G2/1.0

Hello,

  I am linking the following .cpp file to my program (approx. 800
modules),  but the constructor is never called:

Foo.cpp:
#include <iostream>
static class Foo
{
public:
  Foo() { std::cout  << "Foo Constructor is called" << std::endl;}
} foo1;

If I am adding this code snippet to some other .cpp file with more
code and dependencies to other modules, the constructor is called. But
I don't  understand why the constructor sometimes is called and
sometimes not. I am using g++ 3.4.6.
Is this a bug? Is there a work around?

Thanks


reply via email to

[Prev in Thread] Current Thread [Next in Thread]