Small compile error: help request

For this line:

static int pinB = 4;

I get this error:

'pinB' defined but not used [-Werror=unused-variable]

Why would a variable that is defined give a compile error if it just is not used?

I understand that snippets are of not much use, but publishing an entire program with 32k of flash memory in use is not doable here. So all I can ask for is some general advice if at all possible?

I will take a SWAG as I do not know your tool chain or settings but I read that as a warning. Comment it out and the warning should go away.

1 Like

Are you compiling for an ESP32? The ESP32 core turns warnings into errors on warning levels 'more' and 'all'.

platform.txt:

# Arduino Compile Warning Levels
compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall -Werror=all
compiler.warning_flags.all=-Wall -Werror=all -Wextra
1 Like

Thank you both! I consider this "Solved" as it indeed compiles with "Compiler warnings" set to "Default".

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.