Skip to content

Commit 0f891ca

Browse files
author
Ma Lik Keung
committed
added settings for vscode C++
1 parent dd7f2e4 commit 0f891ca

File tree

5 files changed

+237
-0
lines changed

5 files changed

+237
-0
lines changed
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Win32",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"C:\\bin\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include",
8+
"C:\\bin\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++"
9+
],
10+
"defines": [
11+
"_DEBUG",
12+
"UNICODE",
13+
"_UNICODE"
14+
],
15+
"windowsSdkVersion": "8.1",
16+
"compilerPath": "C:\\bin\\MinGW\\bin\\g++.exe",
17+
"cStandard": "c11",
18+
"cppStandard": "c++17",
19+
"intelliSenseMode": "gcc-x64",
20+
"browse": {
21+
"path": [
22+
"${workspaceFolder}/**"
23+
]
24+
}
25+
}
26+
],
27+
"version": 4
28+
}

helloCpp/.vscode/launch.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "(gdb) Launch",
9+
"type": "cppdbg",
10+
"request": "launch",
11+
"program": "${workspaceFolder}/hello.exe",
12+
"args": [],
13+
"stopAtEntry": false,
14+
"cwd": "${workspaceFolder}",
15+
"environment": [],
16+
"externalConsole": true,
17+
"MIMode": "gdb",
18+
"miDebuggerPath": "C:\\bin\\MinGW\\bin\\gdb.exe",
19+
"preLaunchTask": "mybuildtask",
20+
"setupCommands": [
21+
{
22+
"description": "Enable pretty-printing for gdb",
23+
"text": "-enable-pretty-printing",
24+
"ignoreFailures": true
25+
}
26+
]
27+
}
28+
]
29+
}

helloCpp/.vscode/readme.txt

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
https://www.youtube.com/watch?v=DIw02CaEusY
2+
3+
1. MINGGW
4+
5+
http://www.mingw.org/
6+
7+
Download mingw-get-setup.exe
8+
9+
After installing minggw, set your env path e.g. C:\bin\MinGW\bin
10+
11+
2. Set include paths
12+
Edit c_cpp_properties.json (using the bulb bubble, or look for it in Ctrl-P and > )
13+
{
14+
"configurations": [
15+
{
16+
"name": "Win32",
17+
"includePath": [
18+
"${workspaceFolder}/**",
19+
"C:\\bin\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++"
20+
],
21+
"defines": [
22+
"_DEBUG",
23+
"UNICODE",
24+
"_UNICODE"
25+
],
26+
"windowsSdkVersion": "8.1",
27+
"compilerPath": "C:\\bin\\MinGW\\bin\\g++.exe",
28+
"cStandard": "c11",
29+
"cppStandard": "c++17",
30+
"intelliSenseMode": "gcc-x64"
31+
}
32+
],
33+
"version": 4
34+
}
35+
36+
3. Create build task
37+
TASK (Ctrl-P, >, Tasks, Configure tasks, Create Task from template, Others )
38+
Edit tasks.json
39+
{
40+
// See https://go.microsoft.com/fwlink/?LinkId=733558
41+
// for the documentation about the tasks.json format
42+
"version": "2.0.0",
43+
"tasks": [
44+
{
45+
"label": "echo",
46+
"type": "shell",
47+
"command": "g++",
48+
"args": [
49+
"-g", "-o", "hello.exe", "hello.cpp"
50+
],
51+
"group": {
52+
"kind": "build",
53+
"isDefault": true
54+
}
55+
}
56+
]
57+
}
58+
59+
4. Build
60+
Ctrl-Sift-B to build
61+
62+
5. DEBUG
63+
From left menu, click on DEBUG option.
64+
Click the green run arrow, select C++(GDB/LLDB)
65+
66+
Edit launch.json ,
67+
set "miDebuggerPath": "C:\\bin\\MinGW\\bin\\gdb.exe",
68+
set "preLaunchTask": "mybuildtask", (refer to "label" in task.json)
69+
set "program": "${workspaceFolder}/hello.exe",
70+

helloCpp/.vscode/tasks.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "mybuildtask",
8+
"type": "shell",
9+
"command": "g++",
10+
"args": [
11+
"-g", "-o", "vcmain.exe", "vcmain.cpp" ,
12+
"tests/Test01.cpp",
13+
"tests/Test02.cpp",
14+
"tests/Test03.cpp",
15+
"algorithms/ArraySorter.cpp",
16+
"algorithms/Quicksort.cpp",
17+
"copyassign/Device.cpp",
18+
"copymove/MemoryPage.cpp",
19+
"datastructures/BinaryTree.cpp",
20+
"datastructures/TruckloadList.cpp",
21+
"fileio/FileIO.cpp",
22+
"inheritance/Base.cpp",
23+
"inheritance/DerivedA.cpp",
24+
"inheritance/DerivedB.cpp",
25+
"inheritance/DerivedC.cpp",
26+
"loops/Loops.cpp",
27+
"strings/StringUtils.cpp"
28+
],
29+
"group": {
30+
"kind": "build",
31+
"isDefault": true
32+
}
33+
}
34+
]
35+
}

helloCpp/vcmain.cpp

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// the entry point for the console application.
2+
//
3+
4+
#include <iostream>
5+
#include <iomanip>
6+
//#include <thread>
7+
//#include <chrono>
8+
//#include <mutex>
9+
#include "Greet.h"
10+
#include "tests\Test01.h"
11+
#include "tests\Test02.h"
12+
#include "tests\Test03.h"
13+
#include "FileWordsCounter\FileWordsCounter.h"
14+
15+
using namespace std;
16+
17+
int main(int argc, char* argv[]) {
18+
Test01 test01;
19+
//test01.testStringTypes();
20+
test01.testStringUtils();
21+
//test01.testPtrsBasics();
22+
//test01.testRefsBasics();
23+
//test01.testLoops();
24+
//test01.testArraySorter();
25+
//test01.testQuicksort();
26+
//test01.testByteOrder();
27+
//test01.testBitShift();
28+
//test01.testBitMasks();
29+
//test01.testTArray2();
30+
//test01.testFileIO();
31+
//test01.testIsSameClass();
32+
33+
//Greet greeter;
34+
//greeter.sayHello();
35+
36+
//HelloContainers myContainers;
37+
//myContainers.helloVector();
38+
39+
40+
Test02 test02;
41+
/*
42+
test02.testInheritanceInStack();
43+
test02.testInheritanceInHeap();
44+
test02.testCpp11();
45+
test02.testInheritanceInHeap2();
46+
test02.testCpp11unique_ptr();
47+
test02.testCpp11unique_ptr_Move();
48+
test02.testCpp11shared_ptr1();
49+
test02.testCopy();
50+
test02.testAssignment();
51+
test02.testMove();
52+
*/
53+
test02.testCopyAssign();
54+
55+
//testThread();
56+
//testThreads();
57+
//testDeadlockThreads();
58+
//testTruckloadList();
59+
60+
Test03 test03;
61+
//test03.testTruckloadList();
62+
test03.testBinaryTree();
63+
test03.testArrayFloorSearch();
64+
65+
//FileWordsCounter wordsCounter("C:\\temp\\2489.txt");
66+
//wordsCounter.startCount();
67+
//wordsCounter.showTopBySort(20);
68+
69+
cout << endl;
70+
cout << "Q or q key to quit...";
71+
char chWait;
72+
cin >> chWait;
73+
74+
return 0;
75+
}

0 commit comments

Comments
 (0)