Re: copying structs - PPC/Intel different results
Re: copying structs - PPC/Intel different results
- Subject: Re: copying structs - PPC/Intel different results
- From: "Clark Cox" <email@hidden>
- Date: Wed, 28 Jun 2006 14:24:36 -0400
On 6/28/06, Shaun Wexler <email@hidden> wrote:
On Jun 28, 2006, at 5:14 AM, Marc Poirier wrote:
> Given this example:
>
> struct Thingy {
> int a;
> int b;
> int c;
> };
> const Thingy kFirstThingy = { 1, 2, 3 };
> const Thingy kSecondThingy = kFirstThingy;
>
> When compiling with GCC 4.0.1 for PPC code, the three values of
> kSecondThingy are 1, 2, 3. But when compiling with GCC 4.0.1 for
> Intel code, the three values of kSecondThingy are 0, 0, 0.
>
> I'm unsure, is one of these a bug? If so, which? I would tend to
> think the Intel results are wrong, though maybe I'm doing something
> I shouldn't be doing, I'm not sure...
Your named struct is not defined as a type, so you need to fully type
your struct declarations:
Note that this is for C only. For C++, it *is* defined as a type.
const struct Thingy kFirstThingy = { 1, 2, 3 };
const struct Thingy kSecondThingy = kFirstThingy;
Otherwise, just do this:
typedef struct Thingy {
int a;
int b;
int c;
} Thingy;
In C++, this typedef is redundant.
--
Clark S. Cox III
email@hidden
My CV/Resume:
http://homepage.mac.com/clarkcox3/files/Resume.pdf
http://homepage.mac.com/clarkcox3/files/Resume.html
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden