INF: A Case Where BUFF] and *BUFF Are Different

ID Number: Q38024

5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

In Microsoft C versions 5.0, 5.1, 6.0, 6.0a, 6.0ax, and C/C++ version

7.0, when the variable buff has been declared in an assembly-language

program, such as the following

.data

public buff

_buff db 200 dup (0xab)

.data ends

there is a difference between the two following C declarations:

extern unsigned char buff[];

extern unsigned *buff;

The difference is that the first declaration says there is a block of

memory that is named buff; the second says there is something called

buff that is a pointer.

This difference can be seen by referencing buff as follows:

buff[x]

If buff is declared as an array, the referencing is correct.

However, if buff is declared as a pointer, the referencing is

incorrect. The data pointed to by buff (ab in this example) is

translated into a memory address, then x bytes are added to it

generating an incorrect reference.

Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax 7.00