Re: Struct padding (was blank subject)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/26/06, Kirkwood, David A <DAVID.A.KIRKWOOD@xxxxxxxx> wrote:
I have an application that works perfectly in a 32 bit environment, but
does not in a 64 bit environment. I believe

The problem has to do with a structure defined as

            Struct  x {

                        Short aaa
                        Short bbb
                        Char something[12]
                        Long lll
                        Long mmm
            }

Sorry about the capitalization.... I'm condemned to using exchange /
outlook.

After the program starts, I look at the  short variables above and they
are initialized to hex 2020 (both) which are spaces if they were
characters. Since this structure is initialized with a pointer to is (
and its components ) I wonder if in the 64 bit environment I have to
manually pad out the size(s) to even 64 bit boumderies?

How are you initializing the structure?

You usually shouldn't depend on the layout of structures.  There are
cases in which it is necessary, but it is usually better to avoid.  If
you're trying to write the memory region of this structure to a file
on a 32-bit machine and read it on a 64-bit machine it  would be
better to write marshal/unmarshal functions to transform the structure
to/from a platform independent representation.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux