Skip to content

template <typename Generic> can not compile with the lastedt version 1.6.8. #4751

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

Closed
EagleSmith opened this issue Mar 24, 2016 · 9 comments
Closed

Comments

@EagleSmith
Copy link

template <typename Generic>
void DEBUG_WM(Generic text) {
  if (_debug) {
    Serial.print("*WM: ");
    Serial.println(text);
  }
}

it's working fine with Previous version(1.6.7)

@facchinm
Copy link
Member

Hi @EagleSmith ,
I've tested IDE 1.6.7 with your example and it fails to compile, too. Can you give more hints? Like target board, verbose compilation output etc etc

@facchinm facchinm added the Waiting for feedback More information must be provided before we can proceed label Mar 25, 2016
@cmaglie
Copy link
Member

cmaglie commented Mar 25, 2016

just a blind guess, but could be that the function prototype spans over two lines?
What happens if you write:

template <typename Generic> void DEBUG_WM(Generic text) {
  if (_debug) {
    Serial.print("*WM: ");
    Serial.println(text);
  }
}

?

@nickgammon
Copy link

I was about to report something similar when I found this report. If you remove the line break it compiles OK. With the break, the preprocessed code is:

template <typename Generic> 
#line 4 "/tmp/arduino_modified_sketch_455371/sketch_jun04c.ino"
void DEBUG_WM(Generic text) ;
#line 11 "/tmp/arduino_modified_sketch_455371/sketch_jun04c.ino"
void setup();
#line 16 "/tmp/arduino_modified_sketch_455371/sketch_jun04c.ino"
void loop();
#line 4
void DEBUG_WM(Generic text) {
  if (_debug) {
    Serial.print("*WM: ");
    Serial.println(text);
  }
}

Arduino .ino file was:

bool _debug = true;

template <typename Generic> 
void DEBUG_WM(Generic text) {
  if (_debug) {
    Serial.print("*WM: ");
    Serial.println(text);
  }
}

void setup() { }
void loop() { }

Removing the #line directives the problem is it was expanded out to:

template <typename Generic> 
void DEBUG_WM(Generic text) ;
void setup();
void loop();
void DEBUG_WM(Generic text) {

The template line is not repeated. The prototype is OK, but the "real" function (definition) does not get the template line. The regexp or whatever-you-use to find a function declaration needs to allow for a line break in the declaration.


IDE 1.6.8 and 1.6.9.

@VioletGiraffe
Copy link

VioletGiraffe commented Feb 23, 2017

I confirm this is still present in 1.8.1. Uno R3 target.

@facchinm
Copy link
Member

Should be solved by arduino/arduino-builder#182, @VioletGiraffe could you test it? Thx

@VioletGiraffe
Copy link

VioletGiraffe commented Feb 23, 2017

@facchinm : how can I test it? Sorry, I'm new around here :)
Apparently, I need to install Go and build the builder. Can I then use this new builder by replacing the "C:\Program Files (x86)\Arduino\arduino-builder.exe" with the new one?

@facchinm
Copy link
Member

No problem 🙂 You don't need to install go, simply download the build produced by @ArduinoBot (http://downloads.arduino.cc/PR/arduino-builder/arduino-builder-182.zip) and replace the arduino-builder executable in the IDE installation folder with the correct one for your platform.

@VioletGiraffe
Copy link

VioletGiraffe commented Feb 23, 2017

Good to know! Yes, that indeed does solve the problem. Thanks.

@per1234 per1234 removed the Waiting for feedback More information must be provided before we can proceed label Jul 1, 2017
@per1234
Copy link
Collaborator

per1234 commented Jul 1, 2017

I also confirm the issue is solved by arduino/arduino-builder#182 so I'm going to close this.

@EagleSmith if you test the arduino/arduino-builder#182 build and find that the problem still occurs please post a minimal complete sketch that demonstrates the problem in addition to the information requested at #4751 (comment) and I'll reopen.

@per1234 per1234 closed this as completed Jul 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants