Re: Bad Assembly Code Generation?[solved]
Re: Bad Assembly Code Generation?[solved]
- Subject: Re: Bad Assembly Code Generation?[solved]
- From: Kyle Moffett <email@hidden>
- Date: Tue, 3 Sep 2002 18:10:38 -0400
On Sunday, September 1, 2002, at 01:50 AM, Joe Osborn wrote:
GCC was incapable of generating proper assembly code because i didn't
declare the methods, which took and returned c data types, in my
@interfaces. So it assumed objects were involved(but wouldn't
something like that(that being [self setBar:[self bar]+1]; throw an
'invalid operand to binary +' or some such? ah well). Anyway, it's all
working just hunky-dory now.
It thought you were doing pointer addition, which is perfectly
reasonable. Let me show you:
/* The following is structurally equivalent to a
basic object (id) under the objective-c runtime */
typedef struct {
Class *isa
} objid;
typedef objid *id;
id myid = [self bar]; /* This is the default return type */
myid = myid+1; /* Since this is pointer arithmetic,
and the size of objid is 2 (1 ptr), this adds 2 */
[self setBar:myid]; /* The result is, bar += 2; */
Hope That Helps,
Kyle Moffett
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.