I am programming MicroChip's MCU using C, but when I initialize a variable with uint8_t
by using these methods:
(uint8_t) distance = 0;
((uint8_t) distance = 0);
And these methods too (declaration):
(uint8_t) distance;
((uint8_t) distance);
But this is what I received after compilation:
error: use of undeclared identifier 'distance'
BTW, I'm a novice at C programming.
Any help is much appreciated.
stdint.h
should define uint8_t
.
So your .c-file needs to include the above mentioned .h-file before defining a variable of type uint8_t
.
This could look like this:
#include <stdint.h>
int main(void)
{
uint8_t distance_uninitialised; /* Holds an indeterminated value. */
uint8_t distance_initialised = 0;
}