“Unused” Warnings and Errors

GCC compiler flags that control unused warnings include: -Wunused-function-Wunused-label-Wunused-parameter-Wunused-value-Wunused-variable-Wunused (=all of the above) Disable for a single file or section of code

Read More

Functions

memset Sets the number of bytes specified to the value specified starting from the pointer.

Read More

Program stops working after a while

Memory leak Search all instances of malloc(). Is there a corresponding free()? Buffer overrun Are copy functions being used without max buffer size protection? Does all array based memory manipulation code check for max buffer size?

Read More

Commenting general

Commenting out section of code Commenting out code and avoiding error: “/*” within comment [-Werror=comment] This is one of those annoying compiler warnings that will be treated as an error if -Werror is set. Bewst solution is to not use /* */ to comment out sections of code and comments, and instead use #if 0 […]

Read More

Creating CMakeLists.txt file

Create CMakeLists.txt A typical C/C++ SDK uses the CMake build automation tool which needs us to create “CMakeLists.txt”, containing the instructions describing the project sources files and targets. In Visual Studio Code: Menu > File > New File Menu > File > Save As > “CMakeLists.txt” An example to paste this code into the file: […]

Read More

Moving or renaming a project

Typically you can just delete your projects “\build” folder. Other methods CMake has a cache which will have wrong paths after you move or rename a project. To clear it in Visual Studio Code: Settings icon > Command Pallet > Enter “CMake:Delete Cache”

Read More