1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Arduino IDE 2.xに変更したらunused variableエラー

Posted at

事象

Arduino IDE 1.xでコンパイルできていたスケッチが、Arduino IDE 2.xでコンパイルできない。
普段、ワーニングになっていたような部分がエラーと判定される。

(下図ではunused variableがエラーになっている。)
image.png

解決方法

エラー箇所のコードを訂正する、、、のが王道。
とはいえ、ライブラリ内でエラーになっていたりすると、なかなか手が出せない。File > Preferencesにある、SettingsのCompiler warningsをNoneにすることで回避できるときもある。

原因

Compiler warningsの設定値が、Arduino IDE 1.xと2.xで違っていた。(デフォルトに違いがあるのか、わたしが変更していたのかは不明。)

Arduino IDE 1.8.19:
image.png

Arduino IDE 2.0.0:
image.png

Compiler warningsの設定値はNone, Default, More, Allの4つある。この設定値がコンパイルにどう作用するかは、使っているボードパッケージ(と選択しているボード)によって決まる。

いま選択しているArduino core for the ESP32のXIAO_ESP32C3は、それぞれの設定値でこのようにコンパイルオプションが設定されている。(platform.txt

  • Compiler warnings = None
    • -w ... 全ての警告メッセージを抑制する
  • Compiler warnings = Default
    • なし
  • Compiler warnings = More
    • -Wall ... 一般的な警告を有効にする
    • -Werror=all ... 全ての警告をエラーにする
  • Compiler warngings = All
    • -Wall ... 一般的な警告を有効にする
    • -Werror=all ... 全ての警告をエラーにする
    • -Wextra ... "-Wall"で有効にならない、いくつかの警告を有効にする

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?