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
All posts by
Using Strings-Values
Create string incorporating variables – sprintf
Functions
memset Sets the number of bytes specified to the value specified starting from the pointer.
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?
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 […]
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: […]
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”
Scientific Notation
Examples SensorRhHumidity = SensorRhHumidityRaw * 9.5367431640625e-5;
String
Insert a hex character code into a string