-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Arduino-generated temp code throws errors: exit status 1 variable or field 'xxx' declared void #8257
Comments
Please always test using the hourly build of the Arduino IDE before reporting issues here: After doing so, please comment here to let us know whether the problem was resolved or not. If not, then you should provide a Minimal, Complete, and Verifiable Example (MCVE) we can use to reproduce the problem. The code you posted is not very useful for this purpose. |
ok, ftm I can't install a 1.8.7 version, it takes too much time and too many efforts, so for now this is a cutdown test code. /*
*********** This code is for the ESP8266 ***********
* Change GPIOs for different boards
*/
// I2C
#include <Wire.h> // Incl I2C comm, but needed for not getting compile error
// TFT
#include <Adafruit_SSD1306.h> //
#include <Adafruit_GFX.h> //
Adafruit_SSD1306 display(10); //
char LINELEN = 8;
char LINENUM = 4;
typedef struct {
char line[8][20] = {"line0_67 9012345678" ,"line1_6" ,"line2_67" ,
"line3_6789012345678" ,"line4_6789012345678" ,"line5_6789012345678" ,
"line6_6789012345678" ,"line7_6789012345678" };
char act=0, top=0, btm=top+LINENUM;
char subl[12]=" ";
} list;
list mList00;
void strcpysubl(char * dest, char * source, char pos) {
byte l;
memset(dest,' ',sizeof(dest));
strncpy( dest+1, source+pos, LINELEN );
}
void displayMenulist(list mList) {
byte l;
for(byte i=0; i<5; i++) {
strcpysubl( mList.subl, mList.line[i], 0);
l=10 + i*13;
display.setCursor( 0, l); display.print(mList.subl);
Serial.println(mList.subl);
}
display.display();
}
void setup(void)
{
// Start Serial
Serial.begin(115200);
delay(2000); // wait for Serial()
// Start Wire (SDA, SCL)
Wire.begin(D2, D1);
// SSD1306 Init
display.begin(); // Switch OLED
display.clearDisplay(); // Clear the buffer.
display.setFont();
displayMenulist(mList00);
}
void loop() {
} |
The sketch compiles cleanly with IDE master (so it also will with 1.8.7 since the builder didn't change) and esp8266 core 2.4.2. |
thank you for your efforts, strangely I just now can't reproduce this issue with the cut-down code either. |
nonetheless, I am clueless -
|
This is what a MCVE looks like for this issue: void dashboard() {}
typedef struct {
byte x = 42;
} list;
void displayMenulist(list mList) {}
void setup() {}
void loop() {} Do you see how much more simple that makes it for us to reproduce the problem? No need to find and install unnecessary libraries. No distracting code that has nothing to do with the bug. No confusion over which board you need to select. Here's what the code looks like after arduino-builder has generated the function prototypes: #include <Arduino.h>
#line 1 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_modified_sketch_76316\\sketch_dec03a.ino"
#line 1 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_modified_sketch_76316\\sketch_dec03a.ino"
#line 1 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_modified_sketch_76316\\sketch_dec03a.ino"
void dashboard();
#line 7 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_modified_sketch_76316\\sketch_dec03a.ino"
void displayMenulist(list mList);
#line 9 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_modified_sketch_76316\\sketch_dec03a.ino"
void setup();
#line 10 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_modified_sketch_76316\\sketch_dec03a.ino"
void loop();
#line 1 "C:\\Users\\per\\AppData\\Local\\Temp\\arduino_modified_sketch_76316\\sketch_dec03a.ino"
void dashboard() {}
typedef struct {
byte x = 42;
} list;
void displayMenulist(list mList) {}
void setup() {}
void loop() {} You can see the prototype for The error does not occur when compiling using Arduino IDE 1.9.0 beta build 88, which indicates that arduino-preprocessor does correctly handle the function prototype generation in this situation. The workaround is to manually add the void displayMenulist(list mList); arduino-builder does not do prototype generation for any function that already has a prototype. |
thanks for your efforts, too. |
I'm not recommending you to migrate to the hourly or beta builds. The workaround of adding the function prototype is the best solution and that will work fine with your current Arduino IDE 1.8.5. There are some very nice improvements made in the Arduino IDE on every release and I think the upcoming 1.8.8 will be a good one but I do understand wanting to stick with the version that's working for you. We've already discussed your issue with transferring your installation between the Windows machine and RPi on the Arduino Forum. However, as I said before, you should take the time to verify that bugs you find still occur in the hourly build before reporting them here. That doesn't mean you need to switch to using the hourly build full time. You can leave your existing installation in place. You only need to download and extract the hourly build, then run it long enough for a quick test. After that you can go back to whichever IDE version you are comfortable with. Currently, the situation is a little confusing because there is an hourly build and a beta build. It is a bit onerous to need to download the latest version and test with both of those and so I feel that it's reasonable to test only with the hourly build. In this case the beta build is especially relevant since it uses a new sketch preprocessor. Hopefully soon the work in the beta build will get merged and we will be back to only having the hourly build to test with. |
ok, I see that the hourly build is esasier to use for checking than I assumed, even if the 1.8.7 was supposed to produce the same error ;) |
In this very specific case and moment in time, Arduino IDE 1.8.7 is equivalent to the hourly build since they are currently both using the same version of arduino-builder, which does the function prototype generation. However, that could change at any time. That also only applies to the particular processes handled by arduino-builder rather than other bugs that could be caused by problems in the Arduino IDE's Java code. So you should not assume that's always the case. In the case of a bug that you know to be a failure of prototype generation, you could check the arduino-builder release page to see which is the most recent version, then compare that to the version used by the latest Arduino IDE release to see if it's the same. Of course, at some point in the future, function prototype generation will be handled by arduino-preprocessor so at that time you will instead need to check that version. As you can see, it's much more simple in the end just to use the hourly build for testing. |
Arduino-generated temp code throws errors:
exit status 1 variable or field 'displaylist' declared void
(1.8.5)
//
Only if I put the struct definition to the most upper top (i.e., top of the
#defines
), then it compiles.The text was updated successfully, but these errors were encountered: