Skip to content

Output of compile --preprocess is different from the file generated with the Arduino app #333

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
spoenemann opened this issue Aug 8, 2019 · 1 comment · Fixed by #331

Comments

@spoenemann
Copy link

Bug Report

Current behavior

I created a new sketch sketch_july2a with the default content (empty setup and loop functions).
The command

arduino-cli compile --preprocess --fqbn arduino:avr:uno sketch_july2a.ino

gives me the following output (full path of source file replaced with ...):

# 1 ".../sketch_july2a.ino"
# 1 ".../sketch_july2a.ino"
# 2 ".../sketch_july2a.ino"
void setup();
# 7 ".../sketch_july2a.ino"
void loop();
# 2 ".../sketch_july2a.ino"
void setup() {
    // put your setup code here, to run once:

}

void loop() {
    // put your main code here, to run repeatedly:

}

Expected behavior

The generated C++ code is missing #include <Arduino.h>, and the source file and line number instructions should start with #line.

This is the result of compiling the sketch with the Arduino app, which I would also expect as output of the arduino-cli command above:

#include <Arduino.h>
#line 1 ".../sketch_july2a.ino"
#line 1 ".../sketch_july2a.ino"

#line 2 ".../sketch_july2a.ino"
void setup();
#line 7 ".../sketch_july2a.ino"
void loop();
#line 2 ".../sketch_july2a.ino"
void setup() {
    // put your setup code here, to run once:
    
}

void loop() {
    // put your main code here, to run repeatedly:
    
}

Environment

Additional context

I'd like to get the C++ code that is generated as an intermediate step when compiling a sketch.

@masci masci added the kind/bug label Aug 8, 2019
@spoenemann
Copy link
Author

This is what I get by running the arduino-cli compile command without --preprocess and looking for the C++ code in the temp folder:

#include <Arduino.h>
#line 1 ".../sketch_july2a.ino"

void setup() {
    // put your setup code here, to run once:
    
}

void loop() {
    // put your main code here, to run repeatedly:
    
}

It's better than with --preprocess because the #include and #line directives are correct, but it's still different from the original output: it's missing the forward declaration of local procedures.

In any case, I would expect the C++ code to be the same with and without the --preprocess flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants