Why, warning: comparison between signed and unsigned integer expressions?
- From: Lox <skolpojken72@xxxxxxxx>
- Date: Mon, 28 May 2012 23:15:41 -0700 (PDT)
Hello all experts. If I compile the following code (small example) I
get "warning: comparison between signed and unsigned integer
expressions".
void test(void)
{
uint8_t a;
uint32_t i;
a = 10;
for(i = 0; i < (a + 1); i++)
{
}
}
But the following code doesn't give that warning:
void test(void)
{
uint8_t a;
uint32_t i;
a = 10;
for(i = 0; i < (uint32_t)(a + 1); i++)
{
}
}
What is going on here? Why does the compiler think (a + 1) is signed?
.
- Follow-Ups:
- Prev by Date: Re: High-level network programming: is C language suitable for that?
- Next by Date: Re: Why, warning: comparison between signed and unsigned integer expressions?
- Previous by thread: Re: High-level network programming: is C language suitable for that?
- Next by thread: Re: Why, warning: comparison between signed and unsigned integer expressions?
- Index(es):
Relevant Pages
|