POSSIBLE DUPLICATE HERE
What differs is that the answers there don't have much to do with the problem.
Classic print-statements don't show up during remote debugging of raspberry pi until termination of the program. Tested with std::out and printf(). After crossing return 0; all statements get printed at once. Running VScode insiders 1.60.0 on a Win10 machine, ssh-connection to raspberry pi 4
my launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"preLaunchTask": "cmake",
"type": "gdb",
"request": "launch",
"target": "./build/${workspaceFolderBasename}",
"cwd": "${workspaceRoot}",
"externalConsole": true,
"valuesFormatting": "parseText"
}
]
}
my tasks.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558&WT.mc_id=iot-0000-dglover
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "cmake",
"type": "shell",
"options": {
"cwd": "${workspaceRoot}/build"
},
"command": "cmake",
"args": [
"--build",
"${workspaceRoot}/build",
"--config",
"Debug",
"--target",
"all",
"--",
"-j",
"6"
]
}
]
}
example to reproduce:
#include <iostream>
#include <stdio.h>
int main(int, char**) {
std::cout << "Hello, world!\n";
std::cout << "Test!\n";
printf("now in C\n");
for(int i = 0; i < 10; i++){
std::cout << i;
}
return 0;
}
Output at breakpoint:
Running executable
Breakpoint 1, main () at /home/pi/Workspace/learn_cpp/programs_jakob/main.cpp:11
11 std::cout << i;
Output after exit:
Running executable
Hello, world!
Test!
now in C
0123456789
[Inferior 1 (process 6916) exited normally]
Any suggestions?
1. EDIT:
Suggested by @molbdnilo, explicitly flushing works:
#include <iostream>
#include <stdio.h>
int main(int, char**) {
std::cout << "Hello, world!\n";
std::cout << "Test!\n";
printf("now in C\n");
std::cout.flush();
for(int i = 0; i < 10; i++){ //breakpoint
std::cout << i;
}
return 0;
}
Output:
Running executable
Hello, world!
Test!
now in C
Breakpoint 1, main () at /home/pi/Workspace/learn_cpp/programs_jakob/main.cpp:10
10 for(int i = 0; i < 10; i++){