[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: g++ and Static Variables
From: |
Larry I Smith |
Subject: |
Re: g++ and Static Variables |
Date: |
Mon, 02 May 2005 14:49:11 GMT |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.7) Gecko/20050414 |
fewgoodmen@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.
>
> Joe
>
Please don't multi-post.
Here's my reply to your post in gnu.gcc.help:
Well, are you talking about 'C' or 'C++'?
You say 'C', but 'g++' is a C++ compiler, and
files with '.cc' extension are usually C++ files.
'gcc' is the 'C' compiler.
Without a complete source code example that demonstrates
the problem, it is hard for anyone to say what you might
be doing wrong.
Regards,
Larry
--
Anti-spam address, change each 'X' to '.' to reply directly.