Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 ユーザーズマニュアル
製品コード
SW006021-1
MPLAB
®
XC8 C Compiler User’s Guide
DS52053B-page 408
2012 Microchip Technology Inc.
(360) array index out of bounds
(Parser)
An array is being indexed with a constant value that is less than zero, or greater than
or equal to the number of elements in the array. This warning will not be issued when
accessing an array element via a pointer variable, for example:
or equal to the number of elements in the array. This warning will not be issued when
accessing an array element via a pointer variable, for example:
int i, * ip, input[10];
i = input[-2]; /* oops -- this element doesn’t exist */
ip = &input[5];
i = ip[-2]; /* this is okay */
(361) function declared implicit int
(Parser)
Where the compiler encounters a function call of a function whose name is presently
undefined, the compiler will automatically declare the function to be of type int , with
unspecified (K&R style) parameters. If a definition of the function is subsequently
encountered, it is possible that its type and arguments will be different from the earlier
implicit declaration, causing a compiler error. The solution is to ensure that all functions
are defined or at least declared before use, preferably with prototyped parameters. If it
is necessary to make a forward declaration of a function, it should be preceded with the
keywords extern or static as appropriate. For example:
undefined, the compiler will automatically declare the function to be of type int , with
unspecified (K&R style) parameters. If a definition of the function is subsequently
encountered, it is possible that its type and arguments will be different from the earlier
implicit declaration, causing a compiler error. The solution is to ensure that all functions
are defined or at least declared before use, preferably with prototyped parameters. If it
is necessary to make a forward declaration of a function, it should be preceded with the
keywords extern or static as appropriate. For example:
/* I may prevent an error arising from calls below */
void set(long a, int b);
void main(void)
{
/* by here a prototype for set should have seen */
set(10L, 6);
}
(362) redundant "&" applied to array
(Parser)
The address operator & has been applied to an array. Since using the name of an array
gives its address anyway, this is unnecessary and has been ignored, for example:
gives its address anyway, this is unnecessary and has been ignored, for example:
int array[5];
int * ip;
/* array is a constant, not a variable; the & is redundant. */
ip = &array;
(363) redundant "&" or "*" applied to function address
(Parser)
The address operator “&” has been applied to a function. Since using the name of a
function gives its address anyway, this is unnecessary and has been ignored, for
example:
function gives its address anyway, this is unnecessary and has been ignored, for
example:
extern void foo(void);
void main(void)
{
void(*bar)(void);
/* both assignments are equivalent */
bar = &foo;
bar = foo; /* the & is redundant */
}
(364) attempt to modify object qualified *
(Parser)
Objects declared const or code may not be assigned to or modified in any other way
by your program. The effect of attempting to modify such an object is compiler specific.
by your program. The effect of attempting to modify such an object is compiler specific.
const int out = 1234; /* "out" is read only */
out = 0; /* oops --
writing to a read-only object */