warn_any_ptr_int_conv

Controls if the compiler generates a warning when an integral type is explicitly converted to a pointer type or vice versa.

Syntax

#pragma warn_any_ptr_int_conv on | off | reset

Targets
All targets.
Remarks

This pragma is useful to identify potential 64-bit pointer portability issues. An example is shown in Listing 10.34.

Listing 10.34 Example of warn_any_ptr_int_conv

#pragma warn_ptr_int_conv on

short i, *ip

void foo() {
i = (short)ip; // WARNING: integral type is not
// large enough to hold pointer
}

#pragma warn_any_ptr_int_conv on

void bar() {
i = (int)ip; // WARNING: pointer to integral conversion
ip = (short *)i; // WARNING: integral to pointer conversion
}

Remarks

See also pragma warn_ptr_int_conv.

This pragma corresponds to the Pointer/Integral Conversions setting . To check this setting, use __option (warn_any_ptr_int_conv), described in Checking Settings. The default setting is off.