Skip to content

Bug: splitting define causes java regex error and arduino won't compile #1935

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
nothinman opened this issue Mar 16, 2014 · 8 comments
Closed
Assignees
Labels
Component: Preprocessor The Arduino sketch preprocessor converts .ino files into C++ code before compilation
Milestone

Comments

@nothinman
Copy link

This doesn't compile:

define SERIAL_BANNER "\

  1. Scan for sensors\n\
  2. Change sensor I2C address\n\
  3. Show readings for all sensors\n
    "

It causes this:
Exception in thread "Thread-6" java.lang.StackOverflowError
at java.util.regex.Pattern$Branch.match(Pattern.java:4114)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168)
[..]

Changing it to:

define SERIAL_BANNER "1) Scan for sensors\n2) Change sensor I2C address\n3) Show readings for all sensors\n"

makes it work...

Marcin

@ffissore
Copy link
Contributor

What IDE version are you using? IDE 1.5.x has a couple of fixes related to your problem

@agdl
Copy link
Member

agdl commented Jan 12, 2015

Waiting for feedback from too long. Reopen it if needed!

@agdl agdl closed this as completed Jan 12, 2015
@peabo7
Copy link

peabo7 commented Jan 13, 2015

Although this is a pre-pre-processor problem, it is also deprecated C++ syntax. The recommended way to write this is:

#define SERIAL_BANNER
"1) Scan for sensors\n"
"2) Change sensor I2C address\n"
"3) Show readings for all sensors\n"

This takes advantage of the fact that in modern C/C++ compilers, successive string literals are concatenated as if they had been written as a single literal.

Peter Olson

@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 and it compiles your sketch just fine.

@ffissore ffissore reopened this Jan 28, 2015
@ffissore ffissore self-assigned this Jan 28, 2015
@ffissore ffissore removed the Waiting for feedback More information must be provided before we can proceed label Jan 28, 2015
@peabo7
Copy link

peabo7 commented Jan 28, 2015

(I'm not the original poster.)

Tested this fix, it works.

Peter Olson

On January 28, 2015 at 11:18 AM Federico Fissore [email protected]
wrote:

Reopened #1935.


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

@ffissore
Copy link
Contributor

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

@Chris--A
Copy link
Contributor

Using the source for 1.6.5, this does not cause an error.

@cmaglie
Copy link
Member

cmaglie commented May 18, 2015

I confirm that this has been fixed on the latest release. Please reopen if needed.

@cmaglie cmaglie closed this as completed May 18, 2015
@ffissore ffissore modified the milestone: Release 1.6.5 May 20, 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

6 participants