fe********@gmail.com wrote:
I am currently working on changing the compiler from Sun Workshop
to g++ for a mid sized C program. In the C files we have static
variables defined and declared. This works fine with the Sun
Workshop compiler. However under g++ the static variables are
initialized to zero but do not have the value they are assigned
to. For example say file2.cc I have static variable defined and
declared as
static int j = 5;
Variable j seems to have a value of zero and not 5. However any
static variables defined and declared in the file that contains
function main seems to have the value that is assigned to them.
I am using g++ version 3.2.2 in a Solaris 8 environment.
Any help would be appreciated.
Sounds like something else wrong. For example, you should be using
gcc for C programs, because g++ primarily alters the default
libraries used. g++ is for C++, not C. At the same time recognize
how gcc identifies the language, i.e. (unless specifically told
otherwise) by the source extension. .C or .cpp identifies C++,
while .c identifies C.
At any rate this is off-topic for c.l.c, as is anything that is
system or compiler specific. You should look for a newsgroup
dealing with gnu and/or gcc.
Since you are using the broken google groups system, note the info
in my sig below.
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson