From 8aeeb692a7bc86d62dc51598699de4d4f59b0c1c Mon Sep 17 00:00:00 2001 From: Subham Date: Sat, 2 Aug 2025 07:37:09 +0530 Subject: [PATCH 1/4] Update build.cmd --- Code Samples/Fib/build.cmd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Code Samples/Fib/build.cmd b/Code Samples/Fib/build.cmd index 821c62747..8b78dafa9 100644 --- a/Code Samples/Fib/build.cmd +++ b/Code Samples/Fib/build.cmd @@ -1,2 +1,3 @@ +@@ -1,2 +0,0 @@ SET PATH=%PATH%;%1 -g++ -g *.cpp -lpthread --std=c++11 -O0 -o %2 \ No newline at end of file +g++ -g *.cpp -lpthread --std=c++11 -O0 -o %2 From 6b7cebe174020a48d66ae89823c304ce8358b3de Mon Sep 17 00:00:00 2001 From: Subham Sangwan Date: Sun, 9 Nov 2025 10:30:31 +0530 Subject: [PATCH 2/4] samples(Fib): remove build task, update README, remove preLaunchTask from launch.json --- Code Samples/Fib/.vscode/launch.json | 1 - Code Samples/Fib/.vscode/tasks.json | 72 +++++++++++----------------- Code Samples/Fib/README.md | 48 +++++++++++++++++++ 3 files changed, 76 insertions(+), 45 deletions(-) diff --git a/Code Samples/Fib/.vscode/launch.json b/Code Samples/Fib/.vscode/launch.json index 301f8c5f2..b1349d1a4 100644 --- a/Code Samples/Fib/.vscode/launch.json +++ b/Code Samples/Fib/.vscode/launch.json @@ -3,7 +3,6 @@ "configurations": [ { "name": "(gdb) Launch", - "preLaunchTask": "build", "type": "cppdbg", "request": "launch", "args": [], diff --git a/Code Samples/Fib/.vscode/tasks.json b/Code Samples/Fib/.vscode/tasks.json index 104a10aad..49c3004f1 100644 --- a/Code Samples/Fib/.vscode/tasks.json +++ b/Code Samples/Fib/.vscode/tasks.json @@ -1,50 +1,34 @@ +{ + "version": "2.0.0", + "tasks": [] +} +```jsonc +{ + "version": "2.0.0", + "tasks": [] +} +``` +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + // The explicit "build" task was removed because the sample now uses a direct g++ command + // (the Makefile was removed). If you prefer a build task, add one that runs the + // appropriate g++ command for your platform or call `build.cmd` on Windows. + "tasks": [] +} { // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", - "tasks": [ - { - "label": "build", - "type": "shell", - "group": { - "kind": "build", - "isDefault": true - }, - "presentation": { + { + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + // The explicit "build" task was removed because the sample now uses a direct g++ command + // (the Makefile was removed). If you prefer a build task, add one that runs the + // appropriate g++ command for your platform or call `build.cmd` on Windows. + "tasks": [] + } "echo": true, - "reveal": "always", - "focus": false, - "panel": "shared" - }, - "windows": { - "command": "${workspaceRoot}/build.cmd", - "args": [ - "", // Path to the bin folder containing g++ to compile - "fib.exe" // Output executable name - ] - }, - "linux": { - "command": "g++", - "args": [ - "-g", - "*.cpp", - "-lpthread", - "--std=c++11", - "-o", - "fib.out" - ] - }, - "osx": { - "command": "g++", - "args": [ - "-g", - "*.cpp", - "-lpthread", - "--std=c++11", - "-o", - "fib.out" - ] - } - } - ] } diff --git a/Code Samples/Fib/README.md b/Code Samples/Fib/README.md index 6402c911b..a9f9eb045 100644 --- a/Code Samples/Fib/README.md +++ b/Code Samples/Fib/README.md @@ -1,3 +1,51 @@ # Fib +This code sample is to show debugging. Update `launch.json` and `tasks.json` in the `.vscode` folder to use your setup to build and debug. + +## Building + +Use one of the commands below to build the sample. The Makefile was removed and the sample is built with g++ directly. + +```bash +# Linux / macOS +g++ -g *.cpp -std=c++11 -o fib.out + +# Windows (MinGW) +g++ -g *.cpp -std=c++11 -o fib.exe +``` + +On Windows you can also run the included `build.cmd` if you prefer (it expects the path to a MinGW/Cygwin `bin` folder and an output name): + +```powershell +.\build.cmd fib.exe +``` + +After building, use the `launch.json` in this folder (or your own) to debug the produced binary. +```markdown +# Fib + +This code sample is to show debugging. Update `launch.json` and `tasks.json` in the `.vscode` folder to use your setup to build and debug. + +## Building + +Use one of the commands below to build the sample. The Makefile was removed and the sample is built with g++ directly. + +```bash +# Linux / macOS +g++ -g *.cpp -std=c++11 -o fib.out + +# Windows (MinGW) +g++ -g *.cpp -std=c++11 -o fib.exe +``` + +On Windows you can also run the included `build.cmd` if you prefer (it expects the path to a MinGW/Cygwin `bin` folder and an output name): + +```powershell +.\build.cmd fib.exe +``` + +After building, use the `launch.json` in this folder (or your own) to debug the produced binary. +``` +# Fib + This code sample is to show debugging. Update `launch.json` and `tasks.json` in the `.vscode` folder to use your setup to build and debug. \ No newline at end of file From b111d6eaad5b914d2c72edc23bdb84b18aaf73f6 Mon Sep 17 00:00:00 2001 From: Subham Sangwan Date: Sun, 9 Nov 2025 10:41:57 +0530 Subject: [PATCH 3/4] samples(Fib): include build.cmd update --- Code Samples/Fib/build.cmd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Code Samples/Fib/build.cmd b/Code Samples/Fib/build.cmd index 8b78dafa9..05879b7cf 100644 --- a/Code Samples/Fib/build.cmd +++ b/Code Samples/Fib/build.cmd @@ -1,3 +1,3 @@ -@@ -1,2 +0,0 @@ -SET PATH=%PATH%;%1 -g++ -g *.cpp -lpthread --std=c++11 -O0 -o %2 +@echo off +SET PATH=%PATH%;%1 +g++ -g *.cpp --std=c++11 -O0 -o %2 From 455c845068e3c32beea526ac07df331495c747bf Mon Sep 17 00:00:00 2001 From: Subham Sangwan Date: Sun, 9 Nov 2025 11:02:41 +0530 Subject: [PATCH 4/4] samples(Fib): fix warnings in thread.cpp (use snprintf, return) and ignore build artifacts --- .gitignore | 4 ++++ Code Samples/Fib/thread.cpp | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d2a8df0e9..53d6151e7 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,7 @@ OneLocBuild # ignore imported localization xlf directory vscode-translations-import + +# Ignore Fib sample build artifacts +Code Samples/Fib/fib.out +Code Samples/Fib/fib.out.dSYM/ diff --git a/Code Samples/Fib/thread.cpp b/Code Samples/Fib/thread.cpp index bef34e9c7..1e5bd00cb 100644 --- a/Code Samples/Fib/thread.cpp +++ b/Code Samples/Fib/thread.cpp @@ -24,7 +24,7 @@ void * thread_proc(void* ctx) int tid = g_tid++; char thread_name[16]; - sprintf(thread_name, "Thread %d", tid); + snprintf(thread_name, sizeof(thread_name), "Thread %d", tid); #ifdef __APPLE__ pthread_setname_np(thread_name); #else @@ -45,4 +45,5 @@ void * thread_proc(void* ctx) } std::cout << thread_name << " exited!" << std::endl; + return nullptr; } \ No newline at end of file