Memory layout of a data structure: Difference between revisions
Content added Content deleted
No edit summary |
m (Removed extra category tags) |
||
Line 1: | Line 1: | ||
{{task}} |
{{task}} |
||
It is often useful to control the memory layout of fields in a data structure to match an interface control definition, or to interface with hardware. |
It is often useful to control the memory layout of fields in a data structure to match an interface control definition, or to interface with hardware. Define a data structure matching the RS-232 Plug Definition. Use the 9-pin definition for brevity. |
||
Define a data structure matching the RS-232 Plug Definition. Use the 9-pin definition for brevity. |
|||
Pin Settings for Plug |
Pin Settings for Plug |
||
(Reverse order for socket.) |
(Reverse order for socket.) |
||
Line 38: | Line 37: | ||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
[[Category:Ada]] |
|||
type Bit is mod 2; |
type Bit is mod 2; |
||
type Rs_232_Layout is record |
type Rs_232_Layout is record |
||
Line 65: | Line 63: | ||
=={{header|C}}/{{header|C++}}== |
=={{header|C}}/{{header|C++}}== |
||
[[Category:C]] |
|||
[[Category:C++]] |
|||
Note: The order of the fields is implementation-defined (i.e. the first bit might be the least-significant one or the most-significant one). On GCC and MSVC++, the first bit is the least-significant one. |
Note: The order of the fields is implementation-defined (i.e. the first bit might be the least-significant one or the most-significant one). On GCC and MSVC++, the first bit is the least-significant one. |
||
struct RS232_data |
struct RS232_data |