Skip to content

Error message line numbers incorrect when compiling multiple .ino files #1479

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
nickgammon opened this issue Jun 22, 2013 · 4 comments
Closed
Assignees
Labels
Component: IDE The Arduino IDE Component: Preprocessor The Arduino sketch preprocessor converts .ino files into C++ code before compilation
Milestone

Comments

@nickgammon
Copy link

IDE 1.0.4.

Test case:

main sketch:

/*

Test sketch



*/

Open new tab in IDE, create tab named: partb.ino

Put this in partb.ino:

#include <SPI.h>           // SPI library for sending data to the shift registers

byte foo [] = { 
   1,
   2    // <---- this line has the error (line 5)
   3,
   4 };

byte bar [] = 
  {
  5,
  6,
  7,
  8,   // <---- this line given as error line (line 14)
  9,
  10,   
  11};

Compile (eg. with Uno as target).

Error is reported at line 14:

partb:14: error: expected `}' before numeric constant
partb:14: error: expected ',' or ';' before numeric constant
partb:15: error: expected declaration before '}' token

However error is actually at line 5.

Generated combined (concatenated) file in the temporary directory is:

#line 1 "sketch_jun22b.ino"
/*

Test sketch



*/
#line 1 "partb.ino"
#include <SPI.h>           // SPI library for sending data to the shift registers

#include "Arduino.h"
#line 11
byte foo [] = {
   1,
   2    // <---- this line has the error (line 5)
   3,
   4 };

byte bar [] =
  {
  5,
  6,
  7,
  8,   // <---- this line given as error line (line 14)
  9,
  10,
  11};

Note that the #line 11 directive is wrong. It is out by the number of lines in the main sketch. It is not line 11, it is line 3.

The #line directive appears to be out by 9 lines. This appears to be the number of lines in the main sketch, plus one for the #include "Arduino.h" line. (Plus one extra one, depending on which line the error is really on).

This is a simplified version of a much larger sketch that exhibited this problem. In that sketch the line number was way out, making spotting the error very hard.

@nickgammon
Copy link
Author

The #line directive appears to be out by 9 lines.

I can't do simple arithmetic it seems. :)

It was out by 8 lines. That is the 7 lines in the main sketch, plus one for the added include line.

@ffissore ffissore added the New label Feb 27, 2014
@cmaglie cmaglie removed the New label Feb 27, 2014
@Chris--A
Copy link
Contributor

@nickgammon

This appears to be fixed in 1.5.7 and above, the errors below have the correct numbers.

sketch_mar26b.ino:6:4: error: expected '}' before numeric constant
sketch_mar26b.ino:6:4: error: expected ',' or ';' before numeric constant
sketch_mar26b.ino:7:6: error: expected declaration before '}' token

@ffissore
Copy link
Contributor

Note to self: issue still valid despite #2729

@ffissore ffissore self-assigned this May 28, 2015
@ffissore ffissore added the Component: Preprocessor The Arduino sketch preprocessor converts .ino files into C++ code before compilation label May 28, 2015
@ffissore
Copy link
Contributor

Fixed by #3779

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE The Arduino IDE Component: Preprocessor The Arduino sketch preprocessor converts .ino files into C++ code before compilation
Projects
None yet
Development

No branches or pull requests

4 participants