Last active
May 31, 2025 04:20
-
-
Save tapyu/8bced1527e3fdc89e6ab7f4023643000 to your computer and use it in GitHub Desktop.
Revisions
-
tapyu revised this gist
Jun 28, 2024 . 1 changed file with 9 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,8 +11,15 @@ CC = gcc CXX = g++ # Compiler flags CFLAGS = -std=c11 CFLAGS += -Wall -Wextra -Wcast-qual -Wmissing-prototypes -Wshadow CFLAGS += -pedantic # CFLAGS += -ggdb3 # only for debugging purpose CXXFLAGS = -std=c++11 CXXFLAGS += -Wall -Wextra -Wcast-qual -Wmissing-prototypes -Wshadow CXXFLAGS += -pedantic # CXXFLAGS += -ggdb3 # only for debugging purpose # Source files CSRCS = $(wildcard *.c) -
tapyu revised this gist
Jun 28, 2024 . 1 changed file with 22 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -35,41 +35,41 @@ Profilers are essential tools for performance analysis and optimization in softw /path/to/executable ``` 3. Use `gprof` profiler to analyze the `gmon.out` file generated in the previous step along with the executable. ```sh gprof /path/to/executable > flat_profile.txt ``` 1. Obtain the graph plot from the profile performance ```sh \cat flat_profile.txt | gprof2dot | dot -Tpng -o output.png ``` The final result is something like  # Utilize `sanitize` flags to detect issues (memory errors, undefined behavior, thread race conditions, etc.) 1. Set/unset flags to Makefile ```Makefile #CXXFLAGS += -O3 -fno-stack-protector # CXXFLAGS += -pg CXXFLAGS += -ggdb3 CXXFLAGS += -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=null -fno-sanitize=alignment -fsanitize-address-use-after-scope ``` 1. Run the executable with these flags. # Use Valgrind: A memory profiler that can detect memory leaks, memory corruption, and other memory-related issues. 1. Download [Valgrind](https://valgrind.org/downloads/) 2. Set/unset flags to Makefile ```Makefile #CXXFLAGS += -O3 -fno-stack-protector # CXXFLAGS += -pg CXXFLAGS += -ggdb3 ``` 1. Run valgrind along with some imporant flags ``` valgrind --leak-check=full --track-origins=yes /path/to/executable --flags --of --the --executable ``` -
tapyu revised this gist
Jun 28, 2024 . 1 changed file with 15 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,19 +18,23 @@ Profilers are essential tools for performance analysis and optimization in softw # Using `gprof` and `gprof2dot` to obtain plots 1. Install `gprof2dot` ``` pip install gprof2dot ``` 1. Make sure certain flags are disabled ```Makefile CXXFLAGS += -pg # Generate extra code to write profile information suitable for the analysis program prof (for -p) or gprof (for -pg) #CXXFLAGS += -O3 -fno-stack-protector # we don't want any optimization ``` 1. Compile the program with whatever build system tool you are using. ```sh make ``` 1. Execute the program as you normally would. This will generate a profiling data file (typically named `gmon.out`) in the current directory. ```sh /path/to/executable ``` 3. Use `gprof` profiler to analyze the `gmon.out` file generated in the previous step along with the executable. ```sh gprof /path/to/executable > flat_profile.txt ``` -
tapyu revised this gist
Jun 28, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -41,7 +41,7 @@ Profilers are essential tools for performance analysis and optimization in softw The final result is something like  # Utilize `sanitize` flags to detect issues (memory errors, undefined behavior, thread race conditions, etc.) 1. Add flags to Makefile -
tapyu revised this gist
Jun 28, 2024 . 2 changed files with 73 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,8 +6,9 @@ - `c_cpp_properties.json`: settings related to IntelliSense. - `.clang-format`: rules for how your code should be formatted, such as indentation, line length, spacing, and so on. It is based on a predefined style to base the formatting on (in my case, I use the [Google style][3]). - Simple `Makefile` for a basic build system template. - Instructions to analyze a C/C++ code performance. TODO: To create comments for documentation, use [Doxygen][4]. It is very powerful and not so minimalist, so it might be tricky to get started. For documentation generated in the source code. [1]: https://stackoverflow.com/questions/58581500/how-to-fix-debugger-in-vscode-if-you-have-makefile-project-on-c [2]: https://hackernoon.com/how-to-set-up-c-debugging-in-vscode-using-a-makefile This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,71 @@ A profiler is a performance analysis tool used in software development. It measures the behavior of a program by collecting data on various aspects such as execution time, memory usage, and CPU usage. Profilers help developers identify performance bottlenecks and optimize their code. There are several types of profilers, each focusing on different aspects of performance: - CPU Profiler: Measures which parts of the code are consuming the most CPU time. This helps in identifying functions or methods that are slowing down the execution of the program. - Memory Profiler: Tracks memory usage of the application, identifying memory leaks and inefficient memory allocation that can lead to excessive memory consumption. - I/O Profiler: Monitors input/output operations, such as file reads and writes, and network activity, helping to identify slow I/O operations that may be impacting performance. - Concurrency Profiler: Analyzes multi-threaded or parallel applications, identifying issues such as thread contention, deadlocks, and suboptimal thread usage. Profilers are essential tools for performance analysis and optimization in software development. They provide detailed insights into various performance aspects, helping developers improve the efficiency and effectiveness of their applications. Converting profiler output into dot graphs can aid in the visual analysis of performance data, making it easier to understand and address performance issues. ## Example Profilers - **gprof**: A GNU profiler that produces a flat profile and a call graph, showing the time spent in each function and the call hierarchy. - **Valgrind**: A memory profiler that can detect memory leaks, memory corruption, and other memory-related issues. - **perf**: A performance analysis tool for Linux that can profile CPU, cache usage, and other hardware events. - **VisualVM**: A visual tool for profiling Java applications, providing insights into CPU and memory usage, thread activity, and more. - **Instruments**: A profiling tool for macOS and iOS applications, part of Xcode, that provides a variety of performance metrics. --- # Using `gprof` and `gprof2dot` to obtain plots 1. Install `gprof2dot` ``` pip install gprof2dot ``` 1. Make sure certain flags are disabled ```Makefile CXXFLAGS += -pg # Generate extra code to write profile information suitable for the analysis program prof (for -p) or gprof (for -pg) #CXXFLAGS += -O3 -fno-stack-protector # we don't want any optimization ``` 1. Compile the program with whatever build system tool you are using. ```sh make ``` 1. Use `gprof` profiler to analyze the performance of the executable ```sh gprof /path/to/executable > flat_profile.txt ``` 1. Obtain the graph plot from the profile performance ```sh \cat flat_profile.txt | gprof2dot | dot -Tpng -o output.png ``` The final result is something like ) # Utilize `sanitize` flags to detect issues (memory errors, undefined behavior, thread race conditions, etc.) 1. Add flags to Makefile ``` #CXXFLAGS += -O3 -fno-stack-protector # CXXFLAGS += -pg CXXFLAGS += -ggdb3 CXXFLAGS += -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=null -fno-sanitize=alignment -fsanitize-address-use-after-scope ``` 1. Run the executable with these flags. # Use Valgrind: A memory profiler that can detect memory leaks, memory corruption, and other memory-related issues. 1. Download [Valgrind](https://valgrind.org/downloads/) 2. Add flags to Makefile ```Makefile #CXXFLAGS += -O3 -fno-stack-protector # CXXFLAGS += -pg CXXFLAGS += -ggdb3 ``` 1. Run valgrind along with some imporant flags ``` valgrind --leak-check=full --track-origins=yes /path/to/executable --flags --of --the --executable ``` -
tapyu revised this gist
Jun 19, 2024 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,6 +7,10 @@ - `.clang-format`: rules for how your code should be formatted, such as indentation, line length, spacing, and so on. It is based on a predefined style to base the formatting on (in my case, I use the [Google style][3]). - Simple `Makefile` for a basic build system template. TODO: To create comments for documentation, use [Doxygen][4]. It is very powerful and not so minimalist, so it might be tricky to get started. For documentation generated in the source code, [`gLAB` format][5] may be a good initial reference. [1]: https://stackoverflow.com/questions/58581500/how-to-fix-debugger-in-vscode-if-you-have-makefile-project-on-c [2]: https://hackernoon.com/how-to-set-up-c-debugging-in-vscode-using-a-makefile [3]: https://google.github.io/styleguide/cppguide.html [4]: https://www.doxygen.nl/ [5]: https://github.com/tapyu/glab/blob/source-code-v5.5.1/source/core/filter.c#L1516-L1529 -
tapyu revised this gist
Jun 18, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # basic Makefile for building simple C or C++ projects. # Phony targets .PHONY: all clean -
tapyu revised this gist
Jun 18, 2024 . 1 changed file with 13 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,19 @@ all: $(EXEC) # Rule to link the object files to create the executable $(EXEC): $(COBJS) $(CXXOBJS) @if [ -n "$(CSRCS)" -a -z "$(CXXSRCS)" ]; then \ echo $(CC) $(COBJS) -o $(EXEC); \ $(CC) $(COBJS) -o $(EXEC); \ elif [ -z "$(CSRCS)" -a -n "$(CXXSRCS)" ]; then \ echo $(CXX) $(CXXOBJS) -o $(EXEC); \ $(CXX) $(CXXOBJS) -o $(EXEC); \ elif [ -n "$(CSRCS)" -a -n "$(CXXSRCS)" ]; then \ echo "Error: Mixing C and C++ source files is not supported."; \ exit 1; \ else \ echo "No source files found."; \ exit 1; \ fi # Rule to compile C source files into object files %.o: %.c -
tapyu revised this gist
Jun 15, 2024 . 1 changed file with 15 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,29 +6,37 @@ # Executable name EXEC = main # Compilers to use CC = gcc CXX = g++ # Compiler flags CFLAGS = -Wall -Wextra -std=c11 CXXFLAGS = -Wall -Wextra -std=c++11 # Source files CSRCS = $(wildcard *.c) CXXSRCS = $(wildcard *.cpp) # Object files COBJS = $(CSRCS:.c=.o) CXXOBJS = $(CXXSRCS:.cpp=.o) # Default target all: $(EXEC) # Rule to link the object files to create the executable $(EXEC): $(COBJS) $(CXXOBJS) $(CXX) $(COBJS) $(CXXOBJS) -o $(EXEC) # Rule to compile C source files into object files %.o: %.c $(CC) $(CFLAGS) -c $< -o $@ # Rule to compile C++ source files into object files %.o: %.cpp $(CXX) $(CXXFLAGS) -c $< -o $@ # Rule to clean up the build files clean: rm -f $(COBJS) $(CXXOBJS) $(EXEC) -
tapyu revised this gist
Jun 5, 2024 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # basic Makefile for building simple C/C++ projects. # Phony targets .PHONY: all clean -
tapyu revised this gist
Jun 5, 2024 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,21 +1,21 @@ # Phony targets .PHONY: all clean # Executable name EXEC = main # Compiler to use CC = gcc # Compiler flags CFLAGS = -Wall -Wextra -std=c11 # Source files SRCS = $(wildcard *.c) # Object files OBJS = $(SRCS:.c=.o) # Default target all: $(EXEC) @@ -29,4 +29,4 @@ $(EXEC): $(OBJS) # Rule to clean up the build files clean: rm -f $(OBJS) $(EXEC) -
tapyu revised this gist
Jun 5, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ ## C/C++-related files for development in Vscode - VScode files (they go in `.vscode/`) [[1]] [[2]]: - `lauch.json`: debugging configurations. - `taks.json`: create task to build the C/C++ project. - `c_cpp_properties.json`: settings related to IntelliSense. -
tapyu revised this gist
Jun 5, 2024 . 3 changed files with 44 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ ## C/C++-related files for development in Vscode - VScode files (goes in `.vscode/`) [[1]] [[2]]: - `lauch.json`: debugging configurations. - `taks.json`: create task to build the C/C++ project. - `c_cpp_properties.json`: settings related to IntelliSense. - `.clang-format`: rules for how your code should be formatted, such as indentation, line length, spacing, and so on. It is based on a predefined style to base the formatting on (in my case, I use the [Google style][3]). - Simple `Makefile` for a basic build system template. [1]: https://stackoverflow.com/questions/58581500/how-to-fix-debugger-in-vscode-if-you-have-makefile-project-on-c [2]: https://hackernoon.com/how-to-set-up-c-debugging-in-vscode-using-a-makefile [3]: https://google.github.io/styleguide/cppguide.html This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ # Phony targets .PHONY: all clean # Compiler to use CC = gcc # Compiler flags CFLAGS = -Wall -Wextra -std=c11 # Source files SRCS = main.c functions.c # Object files OBJS = $(SRCS:.c=.o) # Executable name EXEC = main # Default target all: $(EXEC) # Rule to link the object files to create the executable $(EXEC): $(OBJS) $(CC) $(OBJS) -o $(EXEC) # Rule to compile source files into object files %.o: %.c $(CC) $(CFLAGS) -c $< -o $@ # Rule to clean up the build files clean: rm -f $(OBJS) $(EXEC) -
tapyu revised this gist
Jun 2, 2024 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,16 +17,16 @@ "version": "2.0.0", "tasks": [ { "label": "Build my C/C++ project", // when pressing Ctrl+Shift+P and selecting `Run Task`, this name will appear "type": "shell", "command": "make", // Change if want to use another approach "group": { "kind": "build", // Indicates that this task is associated with the build process (we can have other kind of tasks, such as test, cleaning, etc.) "isDefault": true }, "problemMatcher": { // VS Code can process the output from a task with a problem matcher. Problem matchers scan the task output text for known warning or error strings, and report these inline in the editor and in the Problems panel. "owner": "cpp", // helps Visual Studio Code organize and present errors and warnings in a relevant context to the user. For example, if you're working on a C/C++ project and the problem matcher's owner is set to "cpp", VSCode will associate errors and warnings detected by this problem matcher with C/C++ files. "Associating" errors and warnings with a specific programming language or file type allows Visual Studio Code to provide targeted assistance and support tailored to the user's current development context "fileLocation": ["relative", "${workspaceFolder}"], // specifies that file paths in error messages are relative to the workspace folder. "pattern": { "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", "file": 1, @@ -38,7 +38,7 @@ } } ] } // NOTE: https://stackoverflow.com/questions/58581500/how-to-fix-debugger-in-vscode-if-you-have-makefile-project-on-c // See https://go.microsoft.com/fwlink/?LinkId=733558 -
tapyu revised this gist
Jun 2, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ { "label": "Build", "type": "shell", "command": "make", // Change if want to use another approach "group": { "kind": "build", "isDefault": true -
tapyu revised this gist
Jun 2, 2024 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,15 +7,19 @@ // execute. For example, you can run the build task to compile your project. // This file defines a build task to compile your C/C++. If this task is the // default one, you can press `ctrl+shift+B` to run it. Concerning how to // build your C/C++ project, it really depends on the developer tastes and // the project complexity. Toy projects can build it by directly running // the compiler (`gcc` or `g++`), but real projects usualy relies on build // systems, such as `Makefile` and `CMake`. { "version": "2.0.0", "tasks": [ { "label": "Build", "type": "shell", "command": "make", // it uses `make` as base to create your executable. Change if want to use another approach "group": { "kind": "build", "isDefault": true -
tapyu revised this gist
Jun 1, 2024 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,16 @@ // - and other language-specific settings. // It is primarily focused on setting up the environment for editing // and understanding the code, rather than building or debugging it. // Note that some configs (e.g., `intelliSenseMode` or the C/C++ // standard) can be set in `settings.json`, whether in local (in // `.vscode/`) or in user settings (in ~/.config/Code/). // When there are conflicting settings between `settings.json` and // `c_cpp_properties.json`, Visual Studio Code (VSCode) will prioritize // the settings in `c_cpp_properties.json` over those in `settings.json` // for IntelliSense-related configurations. Therefore, use this file // for fine tweaking. // NOTE: https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference { -
tapyu revised this gist
Jun 1, 2024 . 1 changed file with 4 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,7 @@ // file is specific to the C/C++ extension for VS Code. It is used // to configure settings related to IntelliSense, providing // - include paths and code navigation // - error checking // - and other language-specific settings. // It is primarily focused on setting up the environment for editing // and understanding the code, rather than building or debugging it. @@ -18,7 +17,7 @@ "/usr/include/poppler" // in a source file. Add other paths here ], "defines": [], // used to set preprocessor macros that will be applied during IntelliSense parsing. This helps the C/C++ extension understand your code better and provide accurate code completion, navigation, and error checking (?) "compilerPath": "/usr/bin/g++", // (optional) The full path to the compiler you use to build your project to enable more accurate IntelliSense "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "gcc-x64" -
tapyu revised this gist
Jun 1, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,5 +24,5 @@ "intelliSenseMode": "gcc-x64" } ], "version": 4 // don't edit this field. It tracks the current version. If it is wrongly changed or deleted, this file is overwritten with a minimal snippet configuration whenever it is saved } -
tapyu revised this gist
Jun 1, 2024 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,12 +2,14 @@ // These tasks can be anything from building your project to running tests or // cleaning up build artifacts. // You can execute tasks defined in tasks.json directly from the Command Palette // (Ctrl+Shift+P) by typing "Run Task" and selecting the task you want to // execute. For example, you can run the build task to compile your project. // This file defines a build task to compile your C/C++. If this task is the // default one, you can press `ctrl+shift+B` to run it { "version": "2.0.0", "tasks": [ { -
tapyu revised this gist
Jun 1, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,5 +24,5 @@ "intelliSenseMode": "gcc-x64" } ], "version": 4 // don't edit this field. It tracks the current version. If it is wrongly changed or deleted, this file is overwritten whenever it is saved } -
tapyu revised this gist
Jun 1, 2024 . 1 changed file with 28 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ // file is specific to the C/C++ extension for VS Code. It is used // to configure settings related to // - IntelliSense, // - including include paths and code navigation // - compiler path // - and other language-specific settings. // It is primarily focused on setting up the environment for editing // and understanding the code, rather than building or debugging it. // NOTE: https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference { "configurations": [ { "name": "My_C/C++_Linux_cfg", // used to differentiate between multiple configurations within a single project or workspace. If you have only one, this doens't make a relevant differece. You can see which config is select in the status bar "includePath": [ "${workspaceFolder}/**", // An include path is a folder that contains header files "/usr/include", // (such as `#include "myHeaderFile.h"`) that are included "/usr/include/poppler" // in a source file. Add other paths here ], "defines": [], // used to set preprocessor macros that will be applied during IntelliSense parsing. This helps the C/C++ extension understand your code better and provide accurate code completion, navigation, and error checking (?) "compilerPath": "/usr/bin/g++", // (optional) The full path to the compiler you use to build your project "cStandard": "c11", "cppStandard": "c++17", "intelliSenseMode": "gcc-x64" } ], "version": 4 } -
tapyu revised this gist
Jun 1, 2024 . 2 changed files with 24 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,10 @@ // used to define debugging configurations. These configurations // specify how the debugger should launch and interact with your // application. Each configuration includes settings for the // debugger type, the program to debug, and any arguments or // environment variables needed. { "version": "0.2.0", "configurations": [ { @@ -24,4 +27,6 @@ ] } ] } // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,19 @@ // The tasks.json file is used to define tasks that can be executed in VS Code. // These tasks can be anything from building your project to running tests or // cleaning up build artifacts. // ou can execute tasks defined in tasks.json directly from the Command Palette // (Ctrl+Shift+P) by typing "Run Task" and selecting the task you want to // execute. For example, you can run the build task to compile your project. { // **defines the default task (press `ctrl+shift+B` to run it) for you C/C++ project** "version": "2.0.0", "tasks": [ { "label": "Build", "type": "shell", "command": "make", // it uses `make` as base to create your executable "group": { "kind": "build", "isDefault": true @@ -26,4 +32,8 @@ } } ] } // NOTE: https://stackoverflow.com/questions/58581500/how-to-fix-debugger-in-vscode-if-you-have-makefile-project-on-c // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format -
tapyu revised this gist
Jun 1, 2024 . 1 changed file with 5 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,17 +4,15 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "C/C++ debug in Vscode", // configures how VS Code will launch the debugger for your application "type": "cppdbg", "request": "launch", // Specifies the type of request. launch means to start a new debug session. "program": "${workspaceFolder}/main", //path to your program "args": [], // array of command-line arguments to pass to the program when it starts "stopAtEntry": false, "cwd": "${workspaceFolder}", // current directory where the program in launch "environment": [], // array of environment variables to set for the debug session "externalConsole": false, "MIMode": "gdb", "setupCommands": [ -
tapyu renamed this gist
Apr 16, 2024 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
tapyu revised this gist
Apr 16, 2024 . 3 changed files with 17 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ Language: Cpp BasedOnStyle: Google AllowShortBlocksOnASingleLine: Empty AllowShortFunctionsOnASingleLine: Empty AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false AlignTrailingComments: true ColumnLimit: 80 DerivePointerAlignment: false LambdaBodyIndentation: OuterScope This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ ## Config files to debug C/C++ code in Vscode - VScode Debug configuration (`lauch.json` and `taks.json`) - https://stackoverflow.com/questions/58581500/how-to-fix-debugger-in-vscode-if-you-have-makefile-project-on-c - https://hackernoon.com/how-to-set-up-c-debugging-in-vscode-using-a-makefile - `.clang-format` to specify rules for how your code should be formatted, such as indentation, line length, spacing, and so on. It is based on a predefined style to base the formatting on (in my case, I use the Google style). - https://walkccc.me/LeetCode/ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +0,0 @@ -
tapyu created this gist
Apr 10, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ ## Config files to debug C/C++ code in Vscode Source: - https://stackoverflow.com/questions/58581500/how-to-fix-debugger-in-vscode-if-you-have-makefile-project-on-c - https://hackernoon.com/how-to-set-up-c-debugging-in-vscode-using-a-makefile This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ { // 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": "C/C++ debug in Vscode", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/main", //path to your program "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ { // NOTE: https://stackoverflow.com/questions/58581500/how-to-fix-debugger-in-vscode-if-you-have-makefile-project-on-c // 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", "command": "make", //its like writing in console make //btw you can others commands like clean make build etc "group": { "kind": "build", "isDefault": true }, "problemMatcher": { "owner": "cpp", "fileLocation": ["relative", "${workspaceFolder}"], "pattern": { "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 } } } ] }