You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An Arduino C-Library calls a weak function which should be defined in the Arduino .ino sketch. Building works for AVR and ESP8266 targets, but generates build errors when building for ESP32.
Sketch
examples/ErriezTest/ErriezTest.ino
#include<Arduino.h>
#include<ErriezTest.h>
#ifdef __cplusplus
extern"C" {
#endif
// Function is called from C-libraryvoidmyCallback()
{
digitalWrite(LED_BUILTIN, HIGH);
}
#ifdef __cplusplus
}
#endifvoidsetup()
{
// Initialize built-in LEDpinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
}
voidloop()
{
}
#include<Arduino.h>
#include"ErriezTest.h"/* Function prototypes */voidmyCallback(void) __attribute__((weak));
externvoidmyCallback(void);
voidfoo(void)
{
if (myCallback != NULL) {
myCallback();
}
}
Debug Message
ErriezTest:44:6: error: conflicting declaration of 'void setup()' with 'C' linkage
void setup()
^~~~~
In file included from /home/user/Arduino/libraries/ErriezTest/examples/ErriezTest/ErriezTest.ino:25:
/home/user/.arduino15/packages/esp32/hardware/esp32/2.0.4/cores/esp32/Arduino.h:136:6: note: previous declaration with 'C++' linkage
void setup(void);
^~~~~
ErriezTest:51:6: error: conflicting declaration of 'void loop()' with 'C' linkage
void loop()
^~~~
In file included from /home/user/Arduino/libraries/ErriezTest/examples/ErriezTest/ErriezTest.ino:25:
/home/user/.arduino15/packages/esp32/hardware/esp32/2.0.4/cores/esp32/Arduino.h:137:6: note: previous declaration with 'C++' linkage
void loop(void);
^~~~
Using library ErriezTest at version 1.0.0 in folder: /home/user/Arduino/libraries/ErriezTest
exit status 1
conflicting declaration of 'void setup()' with 'C' linkage
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
I confirm I have checked existing issues, online documentation and Troubleshooting guide.
The text was updated successfully, but these errors were encountered:
Thanks for your feedback. I did not expect this behavior as it works for AVR and ESP8266 (and maybe more). In the mean time I've found a workaround by adding a callback function, so I'm not blocked on this.
Board
Any ESP32
Device Description
Any ESP32
Hardware Configuration
None.
Version
v2.0.4
IDE Name
Arduino 1.8.19
Operating System
Ubuntu 22.04
Flash frequency
Not relevant
PSRAM enabled
no
Upload speed
Not relevant
Description
An Arduino C-Library calls a weak function which should be defined in the Arduino
.ino
sketch. Building works for AVR and ESP8266 targets, but generates build errors when building for ESP32.Sketch
examples/ErriezTest/ErriezTest.ino
src/ErriezTest.h
src/ErriezTest.c
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: