LwUTIL latest-develop documentation
Welcome to the documentation for version latest-develop.
LwUTIL is a lightweight utility library that collects small helper macros and functions for value comparisons, bit manipulation, endian-aware serialization and a few common algorithms, commonly hand-written again and again in day-to-day C/C++ development.
Download library Getting started Open Github Donate
Features
Written in C (C11), compatible with
stdint.hdata typesGet the minimum or maximum of two values, constrain a value to a range, or map it between two ranges
Get the absolute value of a signed input
Silence “unused variable” compiler warnings
Dereference and assign through a pointer, but only when it is not
NULLCompute the number of elements in a statically allocated array, with
LWUTIL_ASZas a short aliasStore and load
16-bitand32-bitvalues to and from a byte buffer, in little- or big-endian formatPointer-advancing extended variants are available for sequential (de)serialization
Set, clear, toggle or check bits against a bit mask
Convert
8/16/32-bitvalues to their hexadecimal ASCII representationEncode and decode
32-bitvalues in variable-length integer (varint) formatCheck whether a time period has elapsed against a rolling time reference, useful for non-blocking periodic tasks
Calculate a rolling (sliding-window) linear regression slope over fixed-step sample data, with helpers to query window capacity/count and reset it
Assert an expression at compile time
No dynamic memory allocation
User friendly MIT license
Requirements
C compiler
Negligible flash and RAM footprint - only the functions you actually call get linked
Contribute
Fresh contributions are always welcome. Simple instructions to proceed:
Fork Github repository
Respect C style & coding rules used by the library
Create a pull request to
developbranch with new features or bug fixes
Alternatively you may:
Report a bug
Ask for a feature request
License
MIT License
Copyright (c) 2026 Tilen MAJERLE
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.