warn_ptr_int_conv. NXP CodeWarrior Development Studio
विज्ञापन
विज्ञापन
warn_ptr_int_conv
• An equal comparison in a statement that contains a single expression. This check is useful if you use
==
when you meant to use
=
. The listing below shows an example.
Listing 31-19. Confusing = and == Operators in Assignments
a == 0; // WARNING: This is a comparison.
a = 0; // OK: This is an assignment, no warning
• A semicolon (
;
) directly after a while
, if
, or for
statement.
For example, the listing below, generates a warning message.
Listing 31-20. Empty statement
i = sockcount(); while (--i); /* WARNING: empty loop. */
matchsock(i);
If you intended to create an infinite loop, put white space or a comment between the while statement and the semicolon. The statements in the listing below, suppress the above error or warning messages.
Listing 31-21. Intentional empty statements
while (i++) ; /* OK: White space separation. */ while (i++) /* OK: Comment separation */ ;
By default, this pragma is off
.
31.30 warn_ptr_int_conv
Controls the recognition the conversion of pointer values to incorrectly-sized integral values.
Syntax
#pragma warn_ptr_int_conv on | off | reset
Remarks
If you enable this pragma, the compiler issues a warning message if an expression attempts to convert a pointer value to an integral type that is not large enough to hold the pointer value.
Listing 31-22. Example for #pragma warn_ptr_int_conv
#pragma warn_ptr_int_conv on char *my_ptr; char too_small = (char)my_ptr; /* WARNING: char is too small. */
CodeWarrior Development Studio for Power Architecture Processors Build Tools Reference Manual, Rev.
10.6, 02/2014
484 Freescale Semiconductor, Inc.
डाउनलोड
विज्ञापन