| OS | GCC | Clang |
|---|---|---|
| Linux | ||
| Windows |
| OS | GCC | Clang |
|---|---|---|
| Linux | ||
| Windows |
This repository contains the reusabe functions, macros and constantes being used across all my projects.
$ meson setup build
$ meson compile -C build
$ meson install -C build
$ meson wrap install catch2
$ meson setup build
$ meson compile -C build main_test main
$ ./build/main_test
$ ./build/main
PLATFORM_WINDOWSis defined when compiling in Windows Environment (OS)PLATFORM_LINUXis defined when compiling in Linux Environment (OS)PLATFORM_APPLEis defined when compiling in MacOS Environment (OS)
BIT64(index)macro returns a 64-bit unsigned integer with only single bit set at the index passed asindexBIT32(index)macro returns a 32-bit unsigned integer with only single bit set at the index passed asindexBIT16(index)macro returns a 16-bit unsigned integer with only single bit set at the index passed asindexBIT8(index)macro returns a 8-bit unsigned integer with only single bit set at the index passed asindexBIT_MASK32(count)macro returns a 32-bit unsigned integer with its right mostcountbits setBIT16_PACK8(v1, v2)macro returns a 16-bit unsigned integer with its left most 8 bits encodev1and the right most 8 bits encodev2BIT16_UNPACK8(bits, index)macro returns a 8-bit unsigned integer corresponding to the 8 bits starting atindex x 8bit index from the leftBIT32_PACK16(v1, v2)macro returns a 32-bit unsigned integer with its left most 16 bits encodev1and the right most 16 bits encodev2BIT32_UNPACK16(bits, index)macro returns a 16-bit unsigned integer corresponding to the 16 bits starting atindex x 16bit index from the leftBIT32_PACK8(v1, v2, v3, v4)macro returns 32-bit unsigned integer having packed 8-bit valuesv1,v2,v3, andv4sequentially from left to rightBIT32_UNPACK8(bits, index)macro returns 8-bit unsigned integer corresponding to the 8 bits starting atindex x 8from the leftBIT64_PACK32(v1, v2)macro returns 64-bit unsigned integer having packed 32-bit valuesv1, andv2from left to rightBIT64_UNPACK32(bits, index)macro returns 32-bit unsigned integer corresponding to the 32-bits starting atindex x 32from the left
com_assert(condition, description)prints description and breaks the execution whenconditionis false, and it only works inGLOBAL_DEBUGmodecom_assert_wrn(condition, description)issues only a warning whenconditionis false, and it only works inGLOBAL_DEBUGmodecom_assert_called_once()when called inside any function, it make sures the function is called only once in the lifetime of a program otherwise it prints an error and breaks the execution, and it only works inGLOBAL_DEBUGmodecom_assert_not_implemented()when called inside any function, it issues an error when the function is called indicating the function is not implemented yet and not suitable for any use, and it only works inGLOBAL_DEBUGmode_com_assert(condition)works same ascom_assertfunction, however it doesn't require a description, it prints the condition expression as it is, and it only works inGLOBAL_DEBUGmode_com_assert_wrn(condition)works same ascom_assert_wrnfunction, however it doesn't require a description as second argument, it prints the condition expression as it is, and it only works inGLOBAL_DEBUGmode
Given a string of bytes, either loaded from file residing in disk or already existing in the memory as BUFFER (a.k.a buffer_t) object, the set of functions in common/binary_reader.h header can be used to read formatted data out of those bytes.
Example:
// include <disk_manager/file_reader.h> to use load_binary_from_file() function
BUFFER* data = load_binary_from_file("myFile.bin");
// create binary_reader_t object from the base pointer and the number of bytes it points to
binary_reader_t* reader = binary_reader_create(buf_get_ptr(data), buf_get_element_count(data))
// destroy the binary_reader_t object
binary_reader_destroy(reader)
// destroy the BUFFER object
buf_free(data)