General coding techniques and algorithms for C and other languages, targeting various platforms.
This process was designed with a Linux-based flow in mind. It uses CMake to create the build environment. Testing is done through CTest and CuTest.
Most of these examples were built and tested using Ubuntu.
~$ git clone <repo>
~$ cd coding
~$ mkdir build
~$ cd build
~$ cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=clang-toolchain.cmake ..
~$ ninja
~$ cp ../averager/test/input.txt averager/test/
~$ ctest
The examples should build cleanly and all tests should pass. The copy of the averager input data is needed to address the relative path.
Each folder contains a description of the example.
- library_name
- inc
- publically exposed files, typically only library header with types/apis.
- library_name.h
- test
- CMakeLists.txt
- CMake file for creating test executable
- library_name_tests.c
- Unit tests for this library
- main.c
- Generic CuTest main entry point
- CMakeLists.txt
- CMakeLists.txt
- CMake file for library
- library_name.c
- library implementation code
- inc
The CMake build process allows for sharing of libraries without full exposure of the library. Each library builds itself and the unit test. Minimal modification of the CMakeLists.txt files should be necessary.
- Copy template directory and replace all instances of template with your library name
- Create library code in ./library_name.c and add public APIs to ./inc/library_name.h
- Add your library c code to sourcefiles in ./CMakeLists.txt
- Create tests for your library in ./test/library_name_test.c
- if required, add other libraries that your library uses to this CMake file
- target_link_libraries
- Add your test code to ./CMakeLists.txt
- Add your test c code to sourcefiles in ./test/CMakeLists.txt
- Modify top-level CMakeLists.txt file to inlcude your library in the build
- add_subdirectory(library_name)
- run CMake build flow
- Look for errors in the CMake installation (when running "cmake .."). This will indicate there is a problem with a CMakeLists.txt file.
- Use "make VERBOSE=1" to print out the build command. Flags and linked libraries (appearing as "-I<path>") are displayed in the output.
- Real linked list
- FIFO
- sorting algos / styles
- buffer manager
- CPP learnings
- FPGA
Configured in settings.json
{
"vim.insertModeKeyBindingsNonRecursive": [
{
"before": ["j", "j"],
"after": ["<ESC>"]
}
],
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": [";"],
"after": [":"]
},
{
"before": ["leader", "w"],
"after": [],
"commands": [{
"command": "editor.action.trimTrailingWhitespace",
"args": []
}]
}
],
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"workbench.editor.enablePreview": false,
"workbench.editor.enablePreviewFromQuickOpen": false,
"editor.lineNumbers": "relative",
"editor.renderWhitespace": "all",
"workbench.editorAssociations": {
"*.ipynb": "jupyter-notebook"
},
"workbench.editor.untitled.hint": "hidden",
"terminal.integrated.tabs.enabled": true,
"explorer.confirmDelete": false,
"extensions.ignoreRecommendations": true,
"notebook.cellToolbarLocation": {
"default": "right",
"jupyter-notebook": "left"
}
}