-
Notifications
You must be signed in to change notification settings - Fork 252
attachInterrupt and detachInterrupt compiler errors in added .cpp file #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The official Arduino core has the -fpermissive flag set, but MiniCore doesn't. My advice is to fix the initial problem. And it's always a good idea to turn on compiler warnings in the IDE settings.
|
Hi and thanks for the quick response. The code is not my code but I have stripped everything out to demonstrate the issue main.ino file is void setup() { void loop(){ The added file test.cpp is #include <arduino.h> void pin_delimitbit_int() When compiled in minicore atmega328 the compiler error is In function 'void pin_delimitbit_int()': Compiles ok in the Arduino IDE 1.8.6 edit: I can see that detachInterrupt wants a uint8_t parameter. Even though the Arduino IDE allows the parameter to be the ISR reference, the parameter should be digitalPinToInterrupt(interruptPin) |
Well,
If you're interested, here's a bit of history regarding Arduino and the -fpermissive flag. It was a big mistake adding it to the official Arduino core, and I refuse to do the same. arduino/ArduinoCore-avr#268 |
I read the history. -fpermissive should definitely be removed from the Arduino core. Serious errors like this detachInterrupt parameter should not just slip through as warnings. This episode has been a lesson. Unfortunately I am now going to have to thoroughly understand some borrowed code I had expected to just be able to reuse. Thanks for your help. |
Yes, I totally agree. I usually like to know what's going on, so I've turned on all compiler warnings too. I believe the Arduino developers disabled all warnings by default to make the IDE more "pleasing" and less "noisy" for new users. But the compilers give you warnings for a reason! As for the code that didn't compile with MiniCore, I highly doubt it even would work with the official Arduino core either. The detachInterrupt pin expects an interrupt number (0 or 1), so the function passed to detachInterrupt has to be located in memory address 0x0000 or 0x0001. That's very unlikely. Thanks for your understanding and for using MiniCore! I'll close this issue now, but don't be afraid to ask more MiniCore related questions here, I'll still get notified. |
An Atmega328 sketch using an added .cpp file with attachInterrupt(....) and detachInterrupt(...) statements compiles successfully in the Arduino IDE 1.8.6 with no errors.
However the same sketch gives compiler errors on all attachInterrupt and detachInterrupt statements when minicore is set in the Tools menu.
An example of the minicore error is
**sketch\PCB_lin_read_01.cpp: In function 'void pin_delimitbit_int()':
PCB_lin_read_01.cpp:192:41: error: invalid conversion from 'void (*)()' to 'uint8_t {aka unsigned char}' [-fpermissive]
If the same code is in the .ino file, attachInterrupt and detachInterrupt statements appear to compile without minicore errors.
I suspect the issue is related to the use of #include <arduino.h> in the added .cpp file but have not been able to confirm that.
The text was updated successfully, but these errors were encountered: