Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Q&A Time

Name: Anonymous 2010-04-10 17:56

If I write the code int i, j; can I assume that (&i + 1) == &j?

Only sometimes. It's not portable, because in EBCDIC, i and j are not adjacent.

Name: Anonymous 2010-04-10 18:37

While it may be true on most modern arch's and compilers, why would you want to rely on this? Things can get more hairy if you have: char a;int b; alloced on the stack. A lot of modern compilers will use an int to store a for alignment/performance reasons, thus you can't use this trick. If you need reliable in-memory layout, use a struct, and use an implementation dependent pragma to force a certain alignment.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List