C Project Template
CProjectTemplate

UbuntucodecovDoxygen ActionDev

Project template for C programming. Including debugging in VSCODE, makefile and Unit testing (+ Github CI)

Usage

  • make BUILD
  • make RUN
  • make TEST

Features

Debugger with VScode

  • The configuration of debugger are supported under .vscode

Prerequist

  1. Vscode
  2. build-essentials. (Install gdb and xcode if you are using Mac)
  3. Linux
  4. python3.8
  5. pip
  6. pip intall quom (for merging to single c file) [See https://github.com/Viatorus/quom]

How to use this C template

Build and Run with <tt>src/main.c</tt>

make BUILD_RUN

Screen Shot 2021-02-25 at 3 04 42 PM

Unit testing

make TEST

Screen Shot 2021-02-25 at 3 04 06 PM

Set workspace to this project

Workspace

Use the debugger icon on VScode

GDB usage

Gihub CD (Continuouse Documentation)

See issue for tutorial

Continuous Integration (CI)

  • Run unit testing on every push and PR [Thank @sosiristseng]

Continusous Deployment (CD)

  • Merged to single main.c file when tagging or releasing. [Thank @sosiristseng]

Memory Leak Detection with Valgrind

  • The test file is set as test/buil/test.out
  • If you want to test main.c, it can be set simply by modifying the makefile
  • Leakage during test
    LEAK: TEST
    valgrind --leak-check=full --show-leak-kinds=all --verbose ./test/build/test.out
  • Leakage in main.c
    LEAK: BUILD
    valgrind --leak-check=full --show-leak-kinds=all --verbose ./build/main.out
  • noted that if main.out needs input. Use following command
    LEAK: BUILD
    valgrind --leak-check=full --show-leak-kinds=all --verbose ./build/main.out < path2data.in