Skip to content
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

transformation .ino to .cpp fails with multi-line macro definition #1971

Closed
peabo7 opened this issue Mar 28, 2014 · 6 comments
Closed

transformation .ino to .cpp fails with multi-line macro definition #1971

peabo7 opened this issue Mar 28, 2014 · 6 comments
Assignees
Labels
Component: Preprocessor The Arduino sketch preprocessor converts .ino files into C++ code before compilation

Comments

@peabo7
Copy link

peabo7 commented Mar 28, 2014

This code is not properly transformed from .ino to .cpp; the line containing "0" is erroneously emitted right after the #include "Arduino.h" statement resulting in a diagnostic such as:

buggy.ino:5: error: expected unqualified-id before numeric constant

Rewriting the macro "abc" so it fits on one line avoids the problem. Note also that the line number referenced in the error message is not the line number of the macro definition or the expansion, making it difficult to find what is wrong in a large program.

 #define abc \
 0

 void
 setup()
 {
   abc;
 }

 void
 loop()
 {
 }

I saw this using1.5.6-r2 BETA, but have not tested it on previous versions.

Peter Olson

@ffissore
Copy link
Contributor

Are you trying to define abc as \0 (null char) or are you defining the value of abc on a new line on purpose?

@peabo7
Copy link
Author

peabo7 commented Mar 29, 2014

This is a reduction of an example that was much more complicated to the minimum required to illustrate the bug. In the original code, the expression the macro expands to was more complex, and the resulting define did not fit on a single line. Hence, I wrote it with the continuation. My workaround is to tolerate the overly long line and not use continuation to make it easily legible.

Peter Olson

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

Please give a try to the IDEs linked at the bottom of this email on the dev list
https://groups.google.com/a/arduino.cc/forum/#!msg/developers/4X2T3rCxXWM/YNJl6PZuDucJ
We're testing a new preprocessor. Your sketch needs a small change to work: you need to avoid using newlines between function return type and function names. Code void setup instead of

void
setup

@peabo7
Copy link
Author

peabo7 commented Jan 28, 2015

Tested using the Linux 64 bit version. Works fine, thanks!

Will the issue with newlines be fixed? I have been writing all my function
definitions that way for years and would keep to keep doing that.

Peter Olson

On January 28, 2015 at 11:10 AM Federico Fissore notifications@github.com
wrote:

Please give a try to the IDEs linked at the bottom of this email on the dev
list
https://groups.google.com/a/arduino.cc/forum/#!msg/developers/4X2T3rCxXWM/YNJl6PZuDucJ
We're testing a new preprocessor. Your sketch needs a small change to work:
you need to avoid using newlines between function return type and function
names. Code void setup instead of

void
setup

Reply to this email directly or view it on GitHub:
#1971 (comment)

@ffissore
Copy link
Contributor

Problem is with ctags: it reports where the function name is, not where its declaration (return type) starts. I guess this is as far as we can get for now. Code is available at https://github.com/ffissore/ctags if you want to tinker with it

@ffissore
Copy link
Contributor

New preprocessor tracked at #2636. Builds for testing it are available

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

2 participants