The Embedded C Standard Template Library (ECSTL) is a software library for the C programming language. It is a clone of the C++ STL especially for embedded systems without using the heap (malloc/free functions).
The ECSTL achieves its results through the use of macros. This approach provides compile-time polymorphism. Current focus is on implementation of a wide range of CPP STL containers.
Here is a minimal example using the queue container:
#include <stdio.h>
#include <stdlib.h>
#include <queue.h> // Step1: include the header.
// Step2: define queue's properties
DEFINE_QUEUE_TYPE(myqueue_int_t, int, 16);
int main(void)
{
DEFINE_QUEUE(myqueue_int_t, myqueue); // Step3: define queue
int sum = 0;
QUEUE_PUSH(myqueue, 10); //insert data
QUEUE_PUSH(myqueue, 20);
QUEUE_PUSH(myqueue, 30);
while(!QUEUE_EMPTY( myqueue ))
{
sum += *QUEUE_FRONT( myqueue ); //read data
QUEUE_POP( myqueue ); //remove data
}
printf( "The elements of myqueue add up to %d\n", sum );
printf( "\nThe final size of myqueue is %d\n", QUEUE_SIZE( myqueue ));
return 0;
}
And its output:
The elements of myqueue add up to 60
The final size of myqueue is 0
To start using ECSTL you need to make 2 simple steps.
At first your project needs to know about ECSTL. For that you have to add ecstl/include
to the project include paths.
The next step is to include files you need. All modules are created as special macros. For more information see original CPP STL documentation or a ECSTL doxygen documentation.
ECSTL is licensed under the MITBSD. You can freely use it in your commercial or opensource software.
This colection of containers is Not thread safe. The container functions should not be called concurrently by different threads. In case of necessity, use mutex or other ways to protect data from concurrent access.