Skip to content

Commit 99efc3e

Browse files
committed
Fix .c file compile that include <Arduino.h>
Both GIGA and Portenta H7 have the files pure_analog_pins.h which is included within Arduino.h If you should by chance have a .c file either in library or sketch that include Arduino.h such as simple file: foo.c ``` #include <Arduino.h> void foo() { } ``` The build will fail with errors like: ``` In file included from C:\Users\kurte\Documents\Arduino\hardware\arduino-git\ArduinoCore-zephyr\variants\arduino_portenta_h7_stm32h747xx_m7/variant.h:6, from C:\Users\kurte\Documents\Arduino\hardware\arduino-git\ArduinoCore-zephyr\cores\arduino/Arduino.h:133, from C:\Users\kurte\AppData\Local\Temp\.arduinoIDE-unsaved2025512-1916-i38ngk.ik13\sketch_jun12a\foo.c:1: C:\Users\kurte\Documents\Arduino\hardware\arduino-git\ArduinoCore-zephyr\variants\arduino_portenta_h7_stm32h747xx_m7/pure_analog_pins.h:25:1: error: unknown type name 'class' 25 | class PureAnalogPin { | ^~~~~ C:\Users\kurte\Documents\Arduino\hardware\arduino-git\ArduinoCore-zephyr\variants\arduino_portenta_h7_stm32h747xx_m7/pure_analog_pins.h:25:21: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token 25 | class PureAnalogPin { | ^ C:\Users\kurte\Documents\Arduino\hardware\arduino-git\ArduinoCore-zephyr\variants\arduino_portenta_h7_stm32h747xx_m7/pure_analog_pins.h:40:8: error: unknown type name 'PureAnalogPin' 40 | extern PureAnalogPin A0_PURE; | ^~~~~~~~~~~~~ C:\Users\kurte\Documents\Arduino\hardware\arduino-git\ArduinoCore-zephyr\variants\arduino_portenta_h7_stm32h747xx_m7/pure_analog_pins.h:41:8: error: unknown type name 'PureAnalogPin' 41 | extern PureAnalogPin A1_PURE; | ^~~~~~~~~~~~~ C:\Users\kurte\Documents\Arduino\hardware\arduino-git\ArduinoCore-zephyr\variants\arduino_portenta_h7_stm32h747xx_m7/pure_analog_pins.h:42:8: error: unknown type name 'PureAnalogPin' 42 | extern PureAnalogPin A2_PURE; | ^~~~~~~~~~~~~ C:\Users\kurte\Documents\Arduino\hardware\arduino-git\ArduinoCore-zephyr\variants\arduino_portenta_h7_stm32h747xx_m7/pure_analog_pins.h:43:8: error: unknown type name 'PureAnalogPin' 43 | extern PureAnalogPin A3_PURE; | ^~~~~~~~~~~~~ C:\Users\kurte\Documents\Arduino\hardware\arduino-git\ArduinoCore-zephyr\variants\arduino_portenta_h7_stm32h747xx_m7/pure_analog_pins.h:54:57: error: unknown type name 'PureAnalogPin' 54 | void PURE_ANALOG_AS_DIGITAL_ATTRIBUTE pinMode (PureAnalogPin pin, PinMode mode); | ^~~~~~~~~~~~~ C:\Users\kurte\Documents\Arduino\hardware\arduino-git\ArduinoCore-zephyr\variants\arduino_portenta_h7_stm32h747xx_m7/pure_analog_pins.h:55:57: error: unknown type name 'PureAnalogPin' 55 | PinStatus PURE_ANALOG_AS_DIGITAL_ATTRIBUTE digitalRead (PureAnalogPin pin); | ^~~~~~~~~~~~~ C:\Users\kurte\Documents\Arduino\hardware\arduino-git\ArduinoCore-zephyr\variants\arduino_portenta_h7_stm32h747xx_m7/pure_analog_pins.h:56:57: error: unknown type name 'PureAnalogPin' 56 | void PURE_ANALOG_AS_DIGITAL_ATTRIBUTE digitalWrite(PureAnalogPin pin, PinStatus value); | ^~~~~~~~~~~~~ C:\Users\kurte\Documents\Arduino\hardware\arduino-git\ArduinoCore-zephyr\variants\arduino_portenta_h7_stm32h747xx_m7/pure_analog_pins.h:57:24: error: unknown type name 'PureAnalogPin' 57 | int analogRead (PureAnalogPin pin); | ^~~~~~~~~~~~~ C:\Users\kurte\Documents\Arduino\hardware\arduino-git\ArduinoCore-zephyr\variants\arduino_portenta_h7_stm32h747xx_m7/pure_analog_pins.h:58:57: error: unknown type name 'PureAnalogPin' 58 | void PURE_ANALOG_AS_DIGITAL_ATTRIBUTE analogWrite (PureAnalogPin pin, int value); | ^~~~~~~~~~~~~ exit status 1 Compilation error: exit status 1 Fix is to simply add #ifdef __cplusplus to the header files (along with #endif ...
1 parent 3225af7 commit 99efc3e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

variants/arduino_giga_r1_stm32h747xx_m7/pure_analog_pins.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#ifndef _PURE_ANALOG_PINS_
22
#define _PURE_ANALOG_PINS_
3+
#ifdef __cplusplus
34

45
/******************************************************************************
56
* INCLUDE
@@ -54,4 +55,6 @@ void PURE_ANALOG_AS_DIGITAL_ATTRIBUTE analogWrite (PureAnalogPin pin, int v
5455

5556
#undef PURE_ANALOG_AS_DIGITAL_ATTRIBUTE
5657

58+
#endif /* __cplusplus */
59+
5760
#endif /* _PURE_ANALOG_PINS_ */

variants/arduino_portenta_h7_stm32h747xx_m7/pure_analog_pins.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#ifndef _PURE_ANALOG_PINS_
77
#define _PURE_ANALOG_PINS_
8+
#ifdef __cplusplus
89

910
/******************************************************************************
1011
* INCLUDE
@@ -59,4 +60,6 @@ void PURE_ANALOG_AS_DIGITAL_ATTRIBUTE analogWrite (PureAnalogPin pin, int v
5960

6061
#undef PURE_ANALOG_AS_DIGITAL_ATTRIBUTE
6162

63+
#endif /* __cplusplus */
64+
6265
#endif /* _PURE_ANALOG_PINS_ */

0 commit comments

Comments
 (0)