Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
1 change: 0 additions & 1 deletion Code Samples/Fib/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"configurations": [
{
"name": "(gdb) Launch",
"preLaunchTask": "build",
"type": "cppdbg",
"request": "launch",
"args": [],
Expand Down
72 changes: 28 additions & 44 deletions Code Samples/Fib/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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/MinGW/Cygwin/Bin/Folder>", // 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"
]
}
}
]
}
48 changes: 48 additions & 0 deletions Code Samples/Fib/README.md
Original file line number Diff line number Diff line change
@@ -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 <Path\To\MinGW\Bin> 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 <Path\To\MinGW\Bin> 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.
5 changes: 3 additions & 2 deletions Code Samples/Fib/build.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
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
3 changes: 2 additions & 1 deletion Code Samples/Fib/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,4 +45,5 @@ void * thread_proc(void* ctx)
}

std::cout << thread_name << " exited!" << std::endl;
return nullptr;
}