2022-03-01 05:29 AM
I am using STM32 Cube IDE with NUCLEO-L4P5ZG
below is my code
void function (int dir, int runtime){
int Run=1;
int bytes_per_reading_gyro = 72;
int bytes_per_reading_echo = 29;
char gyro_reading[bytes_per_reading_gyro];;
int echo_reading[bytes_per_reading_echo];
[more code below]
}
I want both gyro_reading and echo_reading to be char[], but I get the error 'gyro_reading' undeclared (first use in this function) when I try to declare it as char.
int foo[foo_len]; is fine
char foo[foo_len]; gives 'foo' undeclared (first use in this function)
char foo = 'f'; gives 'foo' undeclared (first use in this function)
char foo[foo_len] = {'\0'}; gives expected expression before '{' token
Is there a way I can declare and use char arrays?
[SOLVED edit] I had used #define char somewhere else in the code
2022-03-01 05:44 AM
Two semi-colons?
Any defines/macros replacing code unexpectedly? Perhaps look at pre-processor output?
Variable size auto allocations? If these are constants perhaps use #define values.
2022-03-01 05:54 AM
Only instance of two semi-colons I can find in the entire file is within for(;;)
Both bytes_per_reading_gyro and bytes_per_reading_echo are constants, so I moved them to main.h and have them as #define values now.
I still can't declare char
I'll look if tthere are defines or macros that interfere.
Thank you
Edit: Also went through the entire file searching with the regex ^([^;]+);([^;]+); to see if there was something missed by searching for ;; found no instances of a semi-colon too many
2022-03-01 06:09 AM
> Only instance of two semi-colons I can find in the entire file is within for(;;)
What about this one?
> char gyro_reading[bytes_per_reading_gyro];;
Doesn't explain the error though. Perhaps mismatched brackets or other syntax error. There's no error in the array declaration.
Was char #defined somewhere?
2022-03-01 06:15 AM
Char was defined somewhere. Removing it solved my issue.
Thank you all!