Skip to content

Editor does not handle backslash at line end of comments [imported] #956

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
cmaglie opened this issue Nov 15, 2012 · 5 comments
Closed

Editor does not handle backslash at line end of comments [imported] #956

cmaglie opened this issue Nov 15, 2012 · 5 comments
Assignees
Labels
Component: Preprocessor The Arduino sketch preprocessor converts .ino files into C++ code before compilation
Milestone

Comments

@cmaglie
Copy link
Member

cmaglie commented Nov 15, 2012

This is Issue 956 moved from a Google Code project.
Added by 2012-06-11T10:01:57.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Defect, Priority-Medium, Component-Core

Original description

I'm using Arduino 1.0.1 and added some comments to a .h file to describe some constants. Some lines contained a backslash at the end. I was surprised that my software did not work correctly. It took me a long time to find out that the trailing backslash was the reason because in the case the next line also will be treated as comment. It would have been much easier for me to find this out if the syntax coloring would have shown the next line in "comment color", too.

Example:
unsigned char values[] = {
45, 12, 56, //
45, 13, 57,
45, 13, 58
};

will be treated as

unsigned char values[] = {
45, 12, 56,
45, 13, 58
};

by the compiler.

@Chris--A
Copy link
Contributor

@ffissore, @cmaglie

In the latest build this does not appear to be the case; the sketch below compiles fine, however its an error. It should cause a compile error and fail.


unsigned char values[] = {
45, 12, 56, // \
45, 13, 57,
45, 13, 58
};

unsigned char values1[] = {
45, 12, 56,
45, 13, 57,
45, 13, 58
};

bool test[ sizeof( values ) == sizeof( values1 ) ? 1 : 0x7FFFFFFFFFFFFFFFULL ];

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

On looking at the pre-processed file, it appears Arduino has removed the comment, and as a result it has un-commented the next line.

So I believe this is now a bug in the IDE pre-processor.

#line 1 "sketch_may27a.ino"

#include "Arduino.h"
void setup();
void loop();
#line 2
unsigned char values[] = {
45, 12, 56,       
45, 13, 57,
45, 13, 58
};

unsigned char values1[] = {
45, 12, 56,
45, 13, 57,
45, 13, 58
};

bool test[ sizeof( values ) == sizeof( values1 ) ? 1 : 0x7FFFFFFFFFFFFFFFULL ];

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

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

Yet another preprocessor issue

@ffissore
Copy link
Contributor

Thanks for the update @Chris--A

@Chris--A
Copy link
Contributor

I've proposed a fix in #3240

@ffissore
Copy link
Contributor

Fixed by #3779

@ffissore ffissore added this to the Release 1.6.6 milestone Sep 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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