arduino / arduino/ArduinoCore-avr

EEPROM variable declared static instead of extern

Open
#399 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

```warning: 'EEPROM' defined but not used [-Wunused-variable]```

This warning occurs because EEPROM.h declares the EEPROM variable as follows:

```static EEPROMClass EEPROM;```

This means that the EEPROM variable is local (not exported) from every file that includes EEPROM.h.

I'm [developing a program](https://github.com/jamessynge/tiny-alpaca-server) using the Arduino framework that has lots of source files. I do unit testing on a linux host, so I find it convenient to have a platform.h header file that includes either the Arduino framework header files that are used by the source file, or my minimal host versions of those Arduino files for execution on host. Among those files is EEPROM.h, so for every .cpp files that includes my platform.h file but doesn't actually use EEPROM I see the warning above. The fix is quite simple, and I'm happy to provide a PR if the team is interested.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading EEPROM.h and inspect how the EEPROM variable is declared and used across files that include it. Confirm the declaration no longer produces unused-variable warnings for translation units that do not use EEPROM, while EEPROM users still build and link correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.