From c4e3ef77d1872cb06d64c1fe2019f75b2c63f0fa Mon Sep 17 00:00:00 2001 From: AlienLogic Date: Sun, 9 Nov 2025 21:25:30 +0100 Subject: [PATCH] Base config for C/C++ project --- .gitignore | 1 + .vscode/launch.json | 23 +++++++++++++++++++++ .vscode/tasks.json | 35 +++++++++++++++++++++++++++++++ readme.md | 1 + src/func.cpp | 10 +++++++++ src/func.h | 6 ++++++ src/main.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 126 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 readme.md create mode 100644 src/func.cpp create mode 100644 src/func.h create mode 100644 src/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d163863 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..5b9dc6a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,23 @@ +{ + "configurations": [ + { + "name": "Compila ed esegui", + "type": "cppvsdbg", + "request": "launch", + "program": "${workspaceFolder}\\build\\app.exe", + "args": [ + "/prova", + "/v", + "/a", + "/h1", + "${workspaceFolder}" + ], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [ ], + "console": "externalTerminal", + "preLaunchTask": "build" + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..995650b --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,35 @@ +{ + "tasks": [ + { + "type": "shell", + "label": "clean", + "command": "del *.*", + "options": { + "cwd": "${workspaceFolder}\\build\\" + }, + "detail": "Pulisci progetto", + "problemMatcher": [ ] + }, + { + "type": "shell", + "label": "build", + "command": "cl.exe", + "args": [ + "/Zi", + "/EHsc", + "/nologo", + "/Fe${workspaceFolder}\\build\\app.exe", + "${workspaceFolder}\\src\\*.cpp" + ], + "options": { + "cwd": "${workspaceFolder}\\build" + }, + "problemMatcher": [ + "$msCompile" + ], + "group": "build", + "detail": "Compila progetto" + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..cdf9b6f --- /dev/null +++ b/readme.md @@ -0,0 +1 @@ +# C/C++ con VS Code \ No newline at end of file diff --git a/src/func.cpp b/src/func.cpp new file mode 100644 index 0000000..6c5f216 --- /dev/null +++ b/src/func.cpp @@ -0,0 +1,10 @@ +#include +#include "func.h" + +using namespace std; + +int addition(int a, int b) +{ + cout << __FILE__ << " - " << __LINE__ << endl; + return a + b; +} \ No newline at end of file diff --git a/src/func.h b/src/func.h new file mode 100644 index 0000000..935088a --- /dev/null +++ b/src/func.h @@ -0,0 +1,6 @@ +#ifndef __FUNC +#define __FUNC + +int addition(int a, int b); + +#endif //__FUNC \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..4a012c9 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include "func.h" + +using namespace std; + +int main(int argc, char *argv[]) +{ + for (size_t i = 0; i < argc; i++) + { + cout << "Arg:\t" << argv[i] << endl; + } + + cout << "\n_MSC_VER\t\t" << _MSC_VER << endl; + cout << "C++ version: " << __cplusplus << endl; + + cout << "\nTEST VECTOR MATRIX" << endl; + + vector> v1{ + vector{"1.1", "1.2", "1.3"}, + vector{"2.1", "2.2", "2.3"}, + vector{"3.1", "3.2", "3.3"}}; + + for (size_t i = 0; i < v1.size(); i++) + { + for (size_t j = 0; j < v1[i].size(); j++) + { + cout << v1[i][j]; + if (v1[i].size() - 1 > j) + cout << " - "; + } + cout << endl; + } + + cout << endl; + + vector msg{"Hello", "World", "from", "VS Code", "and the C++ extension!", "again"}; + + for (const string &word : msg) + { + cout << word << " "; + } + cout << endl; + + cout << "addition: " << addition(900, 110) << endl; + + return ERROR_SUCCESS; +}