Skip to content

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

Closed
@spoenemann

Description

@spoenemann

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions