Skip to content

#line directive is placed at end of code line #7

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
per1234 opened this issue Dec 22, 2017 · 1 comment
Closed

#line directive is placed at end of code line #7

per1234 opened this issue Dec 22, 2017 · 1 comment
Labels
type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Dec 22, 2017

Using Arduino IDE Beta build 31 with Windows 7 64 bit

  1. Download https://github.com/Jomelo/LCDMenuLib2/archive/v1.0.1.zip
  2. Sketch > Include Library > Add .ZIP Library > Select the downloaded file > Open
  3. Tools > Board > Arduino/Genuino Uno
  4. File > Examples > LCDMenuLib2 > 00_beginners > LCDML_000_serialMonitor
  5. Sketch > Verify/Compile

Error output:

LCDML_000_serialMonitor:80:88: error: stray '#' in program

     Serial.begin(9600);                // start serial    

                                                                                        ^

LCDML_000_serialMonitor:80:89: error: 'line' does not name a type

     Serial.begin(9600);                // start serial    

                                                                                         ^

arduino-preprocessor -debug output:
https://gist.github.com/per1234/be01dbe7f6e3aa08b5775298b0c7c67c/raw/9002d3f23689badcaeddfc7de0507d1b332e66c6/arduino-preprocessor_debug_output.txt

The problem occurs at line 10184 of the output:

  const char g_LCDML_DISP_lang_0_var[] __attribute__((__progmem__)) = {"Information"}; #line 47 "E:\\Stuff\\misc\\electronics\\arduino\\libraries\\LCDMenuLib2-1.0.1\\examples\\00_beginners\\LCDML_000_serialMonitor\\LCDML_000_serialMonitor.ino"

Where the #line directive was incorrectly added at the end of the code line.

The issue does not occur with Arduino IDE 1.8.5 or Arduino IDE 1.8.6 Hourly Build 2017/11/13 11:33.

Originally reported by @Jomelo at http://forum.arduino.cc/index.php?topic=518385.

@cmaglie
Copy link
Member

cmaglie commented Dec 22, 2017

smaller test code to reproduce:

int a; int b=forwardDeclared();

void setup() {}
void loop() {}
int forwardDeclared() { return 0; }

@cmaglie cmaglie added the bug label Dec 22, 2017
cmaglie added a commit that referenced this issue Dec 22, 2017
The insertion point of prototypes may be detected to be in the middle
of a line for example in the following sketch:

   int a; int b=forwardDeclared();
   void setup() {}
   void loop() {}
   int forwardDeclared() { return 0; }

the insertion point is determined to be between `int a;` and `int b=..`
since the latter declaration use a forward-declared function to
initialize variable.
Before this patch this resulted in a stray `#line` directive inserted in
the middle of a line:

   int a; #line 1 ......     <- added prototype line
   int forwardDeclared();    <- added prototype
   #line 2.....              <- other prototypes....
   ......

This patch avoids the situation above by inserting a newline just before
the first `#line` directive if the insertion point happens to be in the
middle of a line.

Fix #7
cmaglie added a commit that referenced this issue Dec 26, 2017
The insertion point of prototypes may be detected to be in the middle
of a line for example in the following sketch:

   int a; int b=forwardDeclared();
   void setup() {}
   void loop() {}
   int forwardDeclared() { return 0; }

the insertion point is determined to be between `int a;` and `int b=..`
since the latter declaration use a forward-declared function to
initialize variable.
Before this patch this resulted in a stray `#line` directive inserted in
the middle of a line:

   int a; #line 1 ......     <- added prototype line
   int forwardDeclared();    <- added prototype
   #line 2.....              <- other prototypes....
   ......

This patch avoids the situation above by inserting a newline just before
the first `#line` directive if the insertion point happens to be in the
middle of a line.

Fix #7
cmaglie added a commit that referenced this issue Dec 26, 2017
cmaglie added a commit that referenced this issue Dec 26, 2017
The insertion point of prototypes may be detected to be in the middle
of a line for example in the following sketch:

   int a; int b=forwardDeclared();
   void setup() {}
   void loop() {}
   int forwardDeclared() { return 0; }

the insertion point is determined to be between `int a;` and `int b=..`
since the latter declaration use a forward-declared function to
initialize variable.
Before this patch this resulted in a stray `#line` directive inserted in
the middle of a line:

   int a; #line 1 ......     <- added prototype line
   int forwardDeclared();    <- added prototype
   #line 2.....              <- other prototypes....
   ......

This patch avoids the situation above by inserting a newline just before
the first `#line` directive if the insertion point happens to be in the
middle of a line.

Fix #7
cmaglie added a commit that referenced this issue Dec 26, 2017
@rsora rsora added the type: imperfection Perceived defect in any part of project label Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants