Closed
Description
Describe the problem
The compiler_err
field of the machine readable output formats are incorrect when compiling a .cpp
file.
I use Arduino CLI for compiling a combination of standard .cpp
/.c
/.h
files. Because an .ino
file with the same name as the sketch is required I just put a blank .ino
file inside the folder.
To reproduce
Structure of the test_sketch sketch:
test_sketch/
├── test_sketch.ino (empty file)
├── main.cpp (source code)
Content of main.cpp
:
int main(){
int i;
while(1){
++i // < Missing semicolon to show wrong behaviour
}
return 0;
}
Current behavior
C:\Users\Niklas\Desktop\arduino_cli>arduino-cli compile test_sketch -b arduino:avr:uno --format json
{
"compiler_out": "",
"compiler_err": "\n",
"builder_result": {
"build_path": "C:\\Users\\Niklas\\AppData\\Local\\Temp\\arduino-sketch-305F5EF96041948188E749EEEDCF1C2F",
"board_platform": {
"id": "arduino:avr",
"version": "1.8.4"
},
"build_platform": {
"id": "arduino:avr",
"version": "1.8.4"
}
},
"success": false
}
Error during build: exit status 1
🐛 The value of the compiler_err
field is \n
instead of the error output from the compiler.
Expected behavior
The compiler_err
field of the machine readable output contains the error output from the compiler.
Arduino CLI version
Original report
0.21.1
Last verified with
Operating system
Windows
Operating system version
11
Additional context
When running the command without the --format json
flag the output is correct.
C:\Users\Niklas\Desktop\arduino_cli>arduino-cli compile test_sketch -b arduino:avr:uno
C:\Users\Niklas\Desktop\arduino_cli\test_sketch\main.cpp: In function 'int main()':
C:\Users\Niklas\Desktop\arduino_cli\test_sketch\main.cpp:5:5: error: expected ';' before '}' token
}
^
Error during build: exit status 1
So I suspect it must have something to to with the conversion to JSON.
Issue checklist
- I searched for previous reports in the issue tracker
- I verified the problem still occurs when using the nightly build
- My report contains all necessary details