From d69585b82abfdaede9e8c358982a4953c432e8d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Thu, 17 Sep 2020 22:27:33 +0200 Subject: Resolve DEBUG compilation issues Use NDEBUG conditional instead of DEBUG. Do not call static functions in extern inline ones. Vector.c:67:11: error: static function 'Vector_isConsistent' is used in an inline function with external linkage [-Werror,-Wstatic-in-inline] --- Vector.c | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) (limited to 'Vector.c') diff --git a/Vector.c b/Vector.c index 713d6831..ebddc0d6 100644 --- a/Vector.c +++ b/Vector.c @@ -38,9 +38,9 @@ void Vector_delete(Vector* this) { free(this); } -#ifdef DEBUG +#ifndef NDEBUG -static inline bool Vector_isConsistent(Vector* this) { +static bool Vector_isConsistent(Vector* this) { assert(this->items <= this->arraySize); if (this->owner) { for (int i = 0; i < this->items; i++) @@ -62,7 +62,18 @@ int Vector_count(Vector* this) { return items; } -#endif +Object* Vector_get(Vector* this, int idx) { + assert(idx < this->items); + assert(Vector_isConsistent(this)); + return this->array[idx]; +} + +int Vector_size(Vector* this) { + assert(Vector_isConsistent(this)); + return this->items; +} + +#endif /* NDEBUG */ void Vector_prune(Vector* this) { assert(Vector_isConsistent(this)); @@ -251,33 +262,6 @@ void Vector_set(Vector* this, int idx, void* data_) { assert(Vector_isConsistent(this)); } -#ifdef DEBUG - -inline Object* Vector_get(Vector* this, int idx) { - assert(idx < this->items); - assert(Vector_isConsistent(this)); - return this->array[idx]; -} - -#else - -// In this case, Vector_get is defined as a macro in vector.h - -#endif - -#ifdef DEBUG - -inline int Vector_size(Vector* this) { - assert(Vector_isConsistent(this)); - return this->items; -} - -#else - -// In this case, Vector_size is defined as a macro in vector.h - -#endif - /* static void Vector_merge(Vector* this, Vector* v2) { @@ -303,7 +287,7 @@ void Vector_add(Vector* this, void* data_) { assert(Vector_isConsistent(this)); } -inline int Vector_indexOf(Vector* this, void* search_, Object_Compare compare) { +int Vector_indexOf(Vector* this, void* search_, Object_Compare compare) { Object* search = search_; assert(Object_isA((Object*)search, this->type)); assert(compare); -- cgit v1.2.3