Skip to content

Commit 2617508

Browse files
Only include avr/io.h if __AVR__ is defined
When this file is included, but no MCU type (e.g. `__AVR_ATmega328p__`) is defined, a warning is generated and only a partial set of AVR-specific macros is defined. When using a non-AVR target, no warning should be generated and none of these AVR-specific macros shoudl be made available, so this only includes avr/io.h from `Godmode.h` when `__AVR__` is defined, and do not include it from `avr/pgmspace.h` at all, since it is not actually needed there. This introduces a small compatibility issue: Until recently, `__AVR__` was never defined when running unittests. All included boards now do so, but if anyone has defined custom AVR boards without defining `__AVR__` in their `.arduino-ci.yaml` file, those would no longer work. This is easy enough to fix, though, just add the `__AVR__` define.
1 parent 8b9cbeb commit 2617508

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

cpp/arduino/Godmode.h

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#pragma once
22
#include "ArduinoDefines.h"
3+
#if defined(__AVR__)
34
#include <avr/io.h>
5+
#endif
46
#include "WString.h"
57
#include "PinHistory.h"
68

cpp/arduino/avr/pgmspace.h

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ out = externs.map {|l| l.split("(")[0].split(" ")[-1].gsub("*", "") }.uniq
1414
out.each { |l| puts d(l) }
1515
*/
1616

17-
#include <avr/io.h>
1817
#include <string.h>
1918

2019
#define PROGMEM

0 commit comments

Comments
 (0)