How to Share a Structure Between C and Assembler Modules (39526)
The information in this article applies to:
- Microsoft Macro Assembler (MASM) 5.0
- Microsoft Macro Assembler (MASM) 5.1
- Microsoft Macro Assembler (MASM) 6.0
- Microsoft Macro Assembler (MASM) 6.0a
- Microsoft Macro Assembler (MASM) 6.0b
This article was previously published under Q39526 SUMMARY
You may declare a type with STRUC directive in your MASM module with
the same memory-storage template as the "struct" type declared in your
C module. You also can declare the variable as external with WORD type
if it is a near data, or DWORD type if it is a far data.
In C, the structure may be packed on a 1, 2, or 4-byte boundary. The
2-byte boundary is the default. As a result, the template constructed
in your MASM module may not match the memory storage exactly, unless
pad bytes are specifically added to the template. See the example
below.
In MASM 5.10 and earlier, any template you may create in with the
STRUC directive has to have unique field names throughout the module.
The field names represent the offset relative to the beginning of the
structure. They do not have to be literally the same field names of
the structure defined in the C module.
Modification Type: | Major | Last Reviewed: | 10/17/2003 |
---|
Keywords: | KB39526 |
---|
|