From 45c9460ed8a854a85bc38f38137396516f409c62 Mon Sep 17 00:00:00 2001 From: Alessandro Iezzi Date: Wed, 30 Nov 2022 23:11:18 +0100 Subject: Add version --- Makefile | 3 ++- src/list.c | 6 ++++++ src/list.h | 1 + test/main.c | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a1f8f85..9fd2dc0 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,9 @@ CC = clang SRC != find src -name '*.c' OBJ = ${SRC:.c=.o} +VERSION = 0.0.0 WARNINGS = -Wall -Werror -CFLAGS = ${WARNINGS} -ansi -pedantic -fPIC +CFLAGS = -DVERSION='"${VERSION}"' ${WARNINGS} -ansi -pedantic -fPIC LFLAGS = all: ${OBJ} liblist.so diff --git a/src/list.c b/src/list.c index dc4c20c..afd105c 100644 --- a/src/list.c +++ b/src/list.c @@ -102,3 +102,9 @@ list_item_t *clist_iterator_next(iterator_t *iterator) return current; } + +char * +clist_version(void) +{ + return VERSION; +} diff --git a/src/list.h b/src/list.h index b10c8b1..6bc8c3f 100644 --- a/src/list.h +++ b/src/list.h @@ -42,5 +42,6 @@ void clist_remove (list_t *, list_item_t *); iterator_t clist_iterator (list_t *); int clist_iterator_has_next(iterator_t *); list_item_t *clist_iterator_next (iterator_t *); +char* clist_version (void); #endif diff --git a/test/main.c b/test/main.c index 9eca65c..502e765 100644 --- a/test/main.c +++ b/test/main.c @@ -52,6 +52,7 @@ int main(int argc, char** argv) clist_remove(&list2, r); clist_add_all(&list1, &list2); + printf("Version: %s\n\n", clist_version()); printf("read from list with iterator:\n"); it = clist_iterator(&list1); -- cgit v1.2.3