Re: "PORTING" C > weird char array values displayed in watch window?
Robby <Robby@discussions.microsoft.com> wrote:
t i=0;
// RESET FLASH BUFFER
for(i=0; i<88; i++)
spiFLASH_BUFFER[88] = 97; // <<< buffer assignment!
You are assigning the same value to the same element spiFLASH_BUFFER[88] =
mutliple times. Further, 88 is not a valid index into spiFLASH_BUFFER - =
you have a buffer overrun here. I'm pretty sure you meant =
spiFLASH_BUFFER[i]
unsigned char spiFLASH_BUFFER[88]; // extern declared in exactly one
.c file!
void set_spi_flash_buffer(unsigned char spiFLASH_BUFFER[])
By giving function parameter the same name as a global variable, you are =
confusing yourself.
QUESTION #1:
When the program hits BREAKPOINT #1, the "buffer assignment" line of
code (in setup.c) assigns to the buffer the value of 97.
No it doesn't. It writes the value 97 88 times beyond the end of the =
buffer. The buffer itself remains unchanged.
QUESTION #2:
When the program hits BREAKPOINT #2, the values of the
"spiFLASH_BUFFER[88]" char array are not even displayed anymore in
the watch window ??? All I see in the watch window now is a small
blue cube and 0 as its value, like this:
spiFLASH_BUFFER 0x00e953c0
[] ....0
Within set_spi_flash_buffer, spiFLASH_BUFFER refers to the function's =
parameter, not to the global variable. And since the parameter is =
declared without array size, the debugger doesn't know how many elements =
you expect it to display.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not =
necessarily a good idea. It is hard to be sure where they are going to =
land, and it could be dangerous sitting under them as they fly overhead. =
-- RFC 1925