Thread View: net.lang.c++
3 messages
3 total messages
Started by David Eppstein
Fri, 17 Oct 1986 17:14
C++ and sizeof
Author: David Eppstein
Date: Fri, 17 Oct 1986 17:14
Date: Fri, 17 Oct 1986 17:14
18 lines
1108 bytes
1108 bytes
Is there a good reason why CC expands sizeof itself? E.g. in
test.c: test..c:
struct x { struct x { /* sizeof = 8 */
int a; int _x_a ;
float b; float _x_b ;
}; } ;
int foo(struct x y) int foo (_auto_y )struct x _auto_y ;
{ {
return y.a + sizeof(y); return (_auto_y . _x_a + 8);
} }
why does the sizeof(y) become 8 and not sizeof(struct x)?
Is there some other use CC makes of the size that makes up for the
resulting lack of portability?
--
David Eppstein, eppstein@cs.columbia.edu, seismo!columbia!cs!eppstein
Re: C++ and sizeof
Author: tk
Date: Sun, 19 Oct 1986 23:56
Date: Sun, 19 Oct 1986 23:56
10 lines
1035 bytes
1035 bytes
In article <3522@columbia.UUCP> eppstein@garfield.columbia.edu (David Eppstein) writes: >Is there a good reason why CC expands sizeof itself? E.g. in > ... >why does the sizeof(y) become 8 and not sizeof(struct x)? >Is there some other use CC makes of the size that makes up for the >resulting lack of portability? What lack of portability? If you're counting on the C++ translator to produce "portable C" as its output I think you'll have problems since cfront uses machine dependent size and alignment information.
Re: C++ and sizeof
Author: Frank Adams
Date: Fri, 24 Oct 1986 19:22
Date: Fri, 24 Oct 1986 19:22
20 lines
1659 bytes
1659 bytes
In article <1772@clyde.ATT.COM> tk@moss.UUCP (Thomas Kirk) writes: >In article <3522@columbia.UUCP> eppstein@garfield.columbia.edu (David Eppstein) writes: >>Is there a good reason why CC expands sizeof itself? E.g. in >> ... >>why does the sizeof(y) become 8 and not sizeof(struct x)? >>Is there some other use CC makes of the size that makes up for the >>resulting lack of portability? > >What lack of portability? If you're counting on the C++ translator to produce >"portable C" as its output I think you'll have problems since cfront uses >machine dependent size and alignment information. This fails to answer the question. *What* does cfront use machine dependant size and alignment information for? Off hand, I can't think of anything it does for which this information is necessary, although it is a simplification to be able to carry around numbers instead of expressions for sizes. Frank Adams ihnp4!philabs!pwa-b!mmintl!franka Multimate International 52 Oakland Ave North E. Hartford, CT 06108
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads