PRB: Warning C4040: near/far/huge Ignored

ID Number: Q23978

3.00 4.00 5.00 5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

SYMPTOMS

In Microsoft C version 4.0, the following warning message may be

generated when trying to declare far data in small model:

Warning 40: near/far/huge ignored

In C 5.0, 5.1, 6.0, 6.0a, 6.0ax, and C/C++ version 7.0, the following

message may be generated instead:

Warning C4040: near/far/huge ignored

CAUSE

The far data can be declared in the small-memory model. This

warning means that the far descriptor is improper and/or

unnecessary in the context in which it is being used. Far or huge

arrays should be defined outside of functions, or with the static

storage class if defined within functions.

It also may mean you are trying to make the type of pointer

definition "char * far pvar;" within the body of a function. This

definition attempts to define a pointer to data (either near or

far, depending on the memory model) and place it in a far data

segment outside the default data segment. This process works

properly only if it is a global definition, or if it is defined as

static within the body of the function.

Please note the difference between the above definition and

defining a pointer to far data, which is "char far *pvar;". The

latter definition declares a pointer that can point to data outside

the default data segment, but the pointer itself is within the

default data segment. This declaration is quite acceptable within

the body of a function.

RESOLUTION

Ensure the far descriptor is properly used.

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