Detecting unused variables and functions ??

40 views
Skip to first unread message

Dave

unread,
Jan 30, 2023, 11:51:17 PM1/30/23
to devel...@arduino.cc, ard...@groups.io
I apologise in advance for cross posting this, but I'm desperate.

I am building someone else's monolithic code but it is littered with
unused variables and functions.

Searching for ways to turn detection for these on I came across adding
this to the code :

    #pragma GCC diagnostic warning "-Wunused-variable"

but it doesn't do anything.

Is there a way to turn this on for the Arduino IDE (v1.8.19) ???

Regards,
Dave


Jon Perryman

unread,
Jan 31, 2023, 12:06:37 AM1/31/23
to devel...@arduino.cc, ard...@groups.io
Why are you worried about unused variables? Unused C variables don't get storage allocated unless they are in a struct which is means they are used as part of the struct. Same occurs for unused functions. Am I missing something? 

Warning messages are suppressed as a default. If you want to see them, then you will need to change the arduino studio settings.

--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
To view this discussion on the web visit https://groups.google.com/a/arduino.cc/d/msgid/developers/DB7PR07MB47485AE92D784E24F9FF9DEED3D09%40DB7PR07MB4748.eurprd07.prod.outlook.com.

Billy

unread,
Jan 31, 2023, 3:19:52 AM1/31/23
to devel...@arduino.cc
Make sure you have "Show verbose output during: compilation" checked in the Arduino preferences, and look carefully at how the compiler is invoked. See if that yields any clues. The compiler options are determined partially by the board support package, so it's significant which board you're compiling for.   Compiling for ESP32 (M5Stick), I have these flags in my command line:

...
-Wno-error=unused-function
-Wno-error=unused-variable
-Wno-error=deprecated-declarations
-Wno-unused-parameter


So it looks like this particular board support package is explicitly disabling the unused-variable warning and others.


--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.
To view this discussion on the web visit https://groups.google.com/a/arduino.cc/d/msgid/developers/DB7PR07MB47485AE92D784E24F9FF9DEED3D09%40DB7PR07MB4748.eurprd07.prod.outlook.com.


--
ǝnɥɐuop ʎllıq
Reply all
Reply to author
Forward
0 new messages