arduino-cli
arduino-cli copied to clipboard
Yet an other preprocessing bug (probably).
Describe the problem
A sketch containing a struct
that contains both an enum
with an underlying type specifier and a method definition does not compile under certain circumstances. This issue may be related to issues #1785 and #1822.
To reproduce
The following sketch does not compile,
struct Test {
enum Enum : int {one, two, three};
void test() {}
};
void setup() {}
void loop() {}
instead, an error is raised:
arduino-cli compile --fqbn arduino:avr:pro --warnings all --output-dir build \
--build-property compiler.cpp.extra_flags="-pedantic"
.../x.ino:3:8: error: 'void Test::test()' cannot be overloaded
void test() {}
^~~~
.../x.ino:3:6: error: with 'void Test::test()'
void test() {}
^~~~
When the enum
is removed, its underlying type is not specified or the method test
is replaced by a prototype (and defined later), the sketch compiles without any errors or warnings.
Expected behavior
The sketch is expected to compile. For reference, the following code compiles without any errors or warnings
struct Test {
enum Enum : int {one, two, three};
void test() {}
};
int main() {}
with the following command
g++ -std=c++11 -Wall -Wextra -pedantic x.cc
Arduino CLI version
nightly-20230427 Commit: 0b77c0a Date: 2023-04-27T01:33:22Z
Operating system
Linux
Operating system version
Debian bookworm/sid
Additional context
No response
Issue checklist
- [X] I searched for previous reports in the issue tracker
- [X] I verified the problem still occurs when using the nightly build
- [X] My report contains all necessary details