ID Number: Q69678
6.00 6.00a 6.00ax | 6.00 6.00a
MS-DOS | OS/2
buglist6.00 buglist6.00a buglist6.00ax fixlist7.00
Summary:
SYMPTOMS
The Microsoft C Compiler versions 6.0, 6.0a, and 6.0ax incorrectly
generate the following error when the sample program below is
compiled with the /qc (quick compile) option:
error C2411: 'i': illegal struct/union member in 'operand 2'
This error is also incorrectly generated by Microsoft QuickC versions
2.50 and 2.51.
CAUSE
The problem results from an attempt to reference a structure element
in an inline assembly block. Single data elements (such as char, int,
and so forth) and array elements can be referenced correctly from the
inline assembly, but the structure element is not recognized properly
by the quick compilers.
RESOLTUION
To work around the problem with either the C or QuickC compiler,
assign the structure element to a temporary variable and then
reference the temporary variable (instead of the structure element)
in the inline assembly. This technique is illustrated in the sample
program below in the lines that are commented out.
Another workaround with the C compiler is to remove the /qc option.
STATUS
Microsoft has confirmed this to be a problem in C versions 6.0, 6.0a,
and 6.0ax and QuickC versions 2.50 and 2.51 (buglist2.50 and
buglist2.51). This problem was corrected in C/C++ version 7.0.
More Information:
Sample Code
-----------
/* Compile options needed: /qc (none with QuickC)
*/
struct tag {
int i;
};
void main(void)
{
struct tag s1;
_asm mov ax,s1.i;
/* If the following lines are uncommented and put in place of the
_asm line above, the C2411 error will be eliminated. */
/*
int temp;
temp = s1.i;
_asm mov ax,temp;
*/
}