make ucx C++ compatible again (and add tests for it) - fixes #486

Mon, 18 Nov 2024 22:05:42 +0100

author
Mike Becker <universe@uap-core.de>
date
Mon, 18 Nov 2024 22:05:42 +0100
changeset 988
15b3ca7ee33f
parent 987
53e22f112b11
child 989
8aa57a7fecc4

make ucx C++ compatible again (and add tests for it) - fixes #486

Makefile file | annotate | diff | comparison | revisions
check-all.sh file | annotate | diff | comparison | revisions
configure file | annotate | diff | comparison | revisions
make/clang.mk file | annotate | diff | comparison | revisions
make/gcc.mk file | annotate | diff | comparison | revisions
make/makefile.mk file | annotate | diff | comparison | revisions
make/project.xml file | annotate | diff | comparison | revisions
make/update-rules.sh file | annotate | diff | comparison | revisions
src/Makefile file | annotate | diff | comparison | revisions
src/cx/common.h file | annotate | diff | comparison | revisions
src/cx/json.h file | annotate | diff | comparison | revisions
src/cx/properties.h file | annotate | diff | comparison | revisions
src/cx/tree.h file | annotate | diff | comparison | revisions
src/tree.c file | annotate | diff | comparison | revisions
tests/Makefile file | annotate | diff | comparison | revisions
tests/util_allocator.h file | annotate | diff | comparison | revisions
--- a/Makefile	Tue Nov 12 17:34:04 2024 +0100
+++ b/Makefile	Mon Nov 18 22:05:42 2024 +0100
@@ -44,6 +44,9 @@
 check: config.mk FORCE
 	$(MAKE) -f make/makefile.mk check
 
+check-cxx: config.mk FORCE
+	$(MAKE) -f make/makefile.mk check-cxx
+
 check-coverage: FORCE
 	$(MAKE) -s check
 	@cd src && $(MAKE) check-coverage
--- a/check-all.sh	Tue Nov 12 17:34:04 2024 +0100
+++ b/check-all.sh	Mon Nov 18 22:05:42 2024 +0100
@@ -12,15 +12,29 @@
   fi
 }
 
+function perform_check_cxx
+{
+  # we cannot mute the warnings, so throw every everything
+  if ! make check-cxx > /dev/null 2> /dev/null ; then
+    echo "fail."
+  else
+    echo "ok."
+  fi
+}
+
 for cc in clang gcc; do
   CC=$cc ./configure --debug > /dev/null
   printf "Check $cc... "
   perform_check
+  printf "Check $cc (c++)... "
+  perform_check_cxx
 done
 
 printf "Check w/o szmul builtin... "
 ./configure --debug --disable-szmul-builtin > /dev/null
 perform_check
+printf "Check w/o szmul builtin (c++)... "
+perform_check_cxx
 
 # clean build files and restore config
 make clean > /dev/null
--- a/configure	Tue Nov 12 17:34:04 2024 +0100
+++ b/configure	Mon Nov 18 22:05:42 2024 +0100
@@ -113,6 +113,7 @@
 
 Optional Features:
   --enable-coverage
+  --disable-cxx-tests     the check-cxx makefile target
   --disable-szmul-builtin use custom implementation, instead
 
 __EOF__
@@ -159,6 +160,7 @@
 fi
 
 # features
+FEATURE_CXX_TESTS=auto
 FEATURE_SZMUL_BUILTIN=auto
 
 #
@@ -189,6 +191,8 @@
         "--with-docs="*) OPT_WITH_DOCS=${ARG#--with-docs=} ;;
         "--enable-coverage") FEATURE_COVERAGE=on ;;
         "--disable-coverage") unset FEATURE_COVERAGE ;;
+        "--enable-cxx-tests") FEATURE_CXX_TESTS=on ;;
+        "--disable-cxx-tests") unset FEATURE_CXX_TESTS ;;
         "--enable-szmul-builtin") FEATURE_SZMUL_BUILTIN=on ;;
         "--disable-szmul-builtin") unset FEATURE_SZMUL_BUILTIN ;;
         "-"*) echo "unknown option: $ARG"; abort_configure ;;
@@ -263,6 +267,9 @@
 # check languages
 lang_c=
 lang_cpp=
+if detect_cpp_compiler ; then
+    lang_cpp=1
+fi
 if detect_c_compiler ; then
     lang_c=1
 fi
@@ -335,6 +342,24 @@
     dep_checked_pandoc=1
     return 0
 }
+dependency_error_cxx()
+{
+    print_check_msg "$dep_checked_cxx" "checking for cxx... "
+    # dependency cxx
+    while true
+    do
+        if [ -z "$lang_cpp" ] ; then
+            break
+        fi
+        print_check_msg "$dep_checked_cxx" "yes\n"
+        dep_checked_cxx=1
+        return 1
+    done
+
+    print_check_msg "$dep_checked_cxx" "no\n"
+    dep_checked_cxx=1
+    return 0
+}
 dependency_error_c()
 {
     print_check_msg "$dep_checked_c" "checking for c... "
@@ -612,6 +637,30 @@
 else
     :
 fi
+if [ -n "$FEATURE_CXX_TESTS" ]; then
+    # check dependency
+    if dependency_error_cxx ; then
+        # "auto" features can fail and are just disabled in this case
+        if [ "$FEATURE_CXX_TESTS" = "auto" ]; then
+            DISABLE_FEATURE_CXX_TESTS=1
+        else
+            DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED cxx "
+            ERROR=1
+        fi
+    fi
+    if [ -n "$DISABLE_FEATURE_CXX_TESTS" ]; then
+        unset FEATURE_CXX_TESTS
+    fi
+fi
+if [ -n "$FEATURE_CXX_TESTS" ]; then
+    :
+    cat >> "$TEMP_DIR/make.mk" << __EOF__
+# Enable the check-cxx target
+WITH_CXX_TEST=yes
+__EOF__
+else
+    :
+fi
 if [ -n "$FEATURE_SZMUL_BUILTIN" ]; then
     if [ -n "$DISABLE_FEATURE_SZMUL_BUILTIN" ]; then
         unset FEATURE_SZMUL_BUILTIN
@@ -748,6 +797,11 @@
 else
 echo "  coverage: off"
 fi
+if [ -n "$FEATURE_CXX_TESTS" ]; then
+echo "  cxx-tests: on"
+else
+echo "  cxx-tests: off"
+fi
 if [ -n "$FEATURE_SZMUL_BUILTIN" ]; then
 echo "  szmul-builtin: on"
 else
--- a/make/clang.mk	Tue Nov 12 17:34:04 2024 +0100
+++ b/make/clang.mk	Mon Nov 18 22:05:42 2024 +0100
@@ -3,6 +3,7 @@
 #
 
 CFLAGS =
+CXXFLAGS = -fpermissive
 DEBUG_CC_FLAGS = -g -Wall -Wextra -pedantic
 RELEASE_CC_FLAGS = -O3 -DNDEBUG
 LDFLAGS =
--- a/make/gcc.mk	Tue Nov 12 17:34:04 2024 +0100
+++ b/make/gcc.mk	Mon Nov 18 22:05:42 2024 +0100
@@ -3,6 +3,7 @@
 #
 
 CFLAGS =
+CXXFLAGS = -fpermissive
 DEBUG_CC_FLAGS = -g -Wall -Wextra -pedantic
 RELEASE_CC_FLAGS = -O3 -DNDEBUG
 LDFLAGS =
--- a/make/makefile.mk	Tue Nov 12 17:34:04 2024 +0100
+++ b/make/makefile.mk	Mon Nov 18 22:05:42 2024 +0100
@@ -59,6 +59,15 @@
 test-compile: static FORCE
 	cd tests && $(MAKE)
 
+check-cxx: CXX-AVAILABLE clean test-compile-cxx FORCE
+	$(build_dir)/tests/ucxtest
+
+test-compile-cxx: static FORCE
+	cd tests && $(MAKE) CC=$(CXX) CFLAGS="$(CFLAGS) $(CXXFLAGS)"
+
+CXX-AVAILABLE:
+	test -n "$(WITH_CXX_TEST)"
+
 docs: FORCE
 	@(test "$(WITH_DOCS_API)" = "yes" && cd docs && $(MAKE) all-api) \
 		|| echo "[ Generation of API Docs disabled - skipped ]"
@@ -67,6 +76,6 @@
 
 update-rules: FORCE
 	make/update-rules.sh src
-	CFLAGS='$(CFLAGS) -I../src' make/update-rules.sh tests '$$(TEST_DIR)'
+	make/update-rules.sh tests '$$(TEST_DIR)' '-I../src'
 
 FORCE:
--- a/make/project.xml	Tue Nov 12 17:34:04 2024 +0100
+++ b/make/project.xml	Mon Nov 18 22:05:42 2024 +0100
@@ -66,6 +66,10 @@
         </make>
     </dependency>
 
+    <dependency name="cxx">
+        <lang>cpp</lang>
+    </dependency>
+
     <dependency name="doxygen">
         <test>test -n "$DOXYGEN"</test>
         <make>DOXYGEN=$DOXYGEN</make>
@@ -114,6 +118,14 @@
         <feature name="coverage">
             <dependencies>coverage</dependencies>
         </feature>
+        <feature name="cxx-tests" default="true">
+            <dependencies>cxx</dependencies>
+            <desc>the check-cxx makefile target</desc>
+            <make>
+                # Enable the check-cxx target
+                WITH_CXX_TEST=yes
+            </make>
+        </feature>
         <feature name="szmul-builtin" default="true">
             <desc>use custom implementation, instead</desc>
             <disabled>
--- a/make/update-rules.sh	Tue Nov 12 17:34:04 2024 +0100
+++ b/make/update-rules.sh	Mon Nov 18 22:05:42 2024 +0100
@@ -2,6 +2,7 @@
 
 dir="$1"
 target="$2"
+extra_flags="$3"
 
 if [ -z "$dir" ]; then
   echo "Usage: $0 <src_dir>"
@@ -46,8 +47,8 @@
 sed '/FORCE:/q' Makefile.old > Makefile
 echo >> Makefile
 for file in `ls *.c` ; do
-  "$CC" -MT "$target/${file/.c/\$(OBJ_EXT)}" -MM $CFLAGS "$file"
+  "$CC" -MT "$target/${file/.c/\$(OBJ_EXT)}" -MM $CFLAGS $extra_flags "$file"
   printf '\t@echo "Compiling $<"\n'
-  printf '\t$(CC) -o $@ $(CFLAGS) -c $<\n\n'
+  printf '\t$(CC) -o $@ $(CFLAGS) %s -c $<\n\n' "$extra_flags"
 done  >> Makefile
 rm Makefile.old
--- a/src/Makefile	Tue Nov 12 17:34:04 2024 +0100
+++ b/src/Makefile	Mon Nov 18 22:05:42 2024 +0100
@@ -68,90 +68,90 @@
 
 $(build_dir)/allocator$(OBJ_EXT): allocator.c cx/allocator.h cx/common.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/array_list$(OBJ_EXT): array_list.c cx/array_list.h cx/list.h \
  cx/common.h cx/collection.h cx/allocator.h cx/iterator.h cx/compare.h \
  cx/compare.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/buffer$(OBJ_EXT): buffer.c cx/buffer.h cx/common.h \
  cx/allocator.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/compare$(OBJ_EXT): compare.c cx/compare.h cx/common.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/hash_key$(OBJ_EXT): hash_key.c cx/hash_key.h cx/common.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/hash_map$(OBJ_EXT): hash_map.c cx/hash_map.h cx/map.h \
  cx/common.h cx/collection.h cx/allocator.h cx/iterator.h cx/compare.h \
  cx/string.h cx/hash_key.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/iterator$(OBJ_EXT): iterator.c cx/iterator.h cx/common.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/json$(OBJ_EXT): json.c cx/json.h cx/common.h cx/string.h \
  cx/allocator.h cx/array_list.h cx/list.h cx/collection.h cx/iterator.h \
  cx/compare.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/linked_list$(OBJ_EXT): linked_list.c cx/linked_list.h \
  cx/common.h cx/list.h cx/collection.h cx/allocator.h cx/iterator.h \
  cx/compare.h cx/compare.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/list$(OBJ_EXT): list.c cx/list.h cx/common.h cx/collection.h \
  cx/allocator.h cx/iterator.h cx/compare.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/map$(OBJ_EXT): map.c cx/map.h cx/common.h cx/collection.h \
  cx/allocator.h cx/iterator.h cx/compare.h cx/string.h cx/hash_key.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/mempool$(OBJ_EXT): mempool.c cx/mempool.h cx/common.h \
  cx/allocator.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/printf$(OBJ_EXT): printf.c cx/printf.h cx/common.h \
  cx/string.h cx/allocator.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/properties$(OBJ_EXT): properties.c cx/properties.h \
  cx/common.h cx/string.h cx/allocator.h cx/map.h cx/collection.h \
  cx/iterator.h cx/compare.h cx/hash_key.h cx/array_list.h cx/list.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/streams$(OBJ_EXT): streams.c cx/streams.h cx/common.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/string$(OBJ_EXT): string.c cx/string.h cx/common.h \
  cx/allocator.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/szmul$(OBJ_EXT): szmul.c cx/common.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
 $(build_dir)/tree$(OBJ_EXT): tree.c cx/tree.h cx/common.h cx/collection.h \
  cx/allocator.h cx/iterator.h cx/compare.h cx/array_list.h cx/list.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS)  -c $<
 
--- a/src/cx/common.h	Tue Nov 12 17:34:04 2024 +0100
+++ b/src/cx/common.h	Mon Nov 18 22:05:42 2024 +0100
@@ -330,6 +330,9 @@
  * @return zero, if no overflow occurred and the result is correct, non-zero
  * otherwise
  */
+#if __cplusplus
+extern "C"
+#endif
 int cx_szmul_impl(size_t a, size_t b, size_t *result);
 
 #endif // cx_szmul
--- a/src/cx/json.h	Tue Nov 12 17:34:04 2024 +0100
+++ b/src/cx/json.h	Mon Nov 18 22:05:42 2024 +0100
@@ -183,6 +183,36 @@
 cx_attr_access_r(2, 3)
 int cxJsonFilln(CxJson *json, const char *buf, size_t len);
 
+#ifdef __cplusplus
+} // extern "C"
+
+cx_attr_nonnull
+static inline int cxJsonFill(
+        CxJson *json,
+        cxstring str
+) {
+    return cxJsonFilln(json, str.ptr, str.length);
+}
+
+cx_attr_nonnull
+static inline int cxJsonFill(
+        CxJson *json,
+        cxmutstr str
+) {
+    return cxJsonFilln(json, str.ptr, str.length);
+}
+
+cx_attr_nonnull
+cx_attr_cstr_arg(2)
+static inline int cxJsonFill(
+        CxJson *json,
+        const char *str
+) {
+    return cxJsonFilln(json, str, strlen(str));
+}
+
+extern "C" {
+#else // __cplusplus
 #define cxJsonFill(json, str) _Generic((str), \
     cxstring: cx_json_fill_cxstr,             \
     cxmutstr: cx_json_fill_mutstr,            \
@@ -214,6 +244,7 @@
 ) {
     return cxJsonFilln(json, str, strlen(str));
 }
+#endif
 
 void cxJsonValueFree(CxJsonValue *value);
 
--- a/src/cx/properties.h	Tue Nov 12 17:34:04 2024 +0100
+++ b/src/cx/properties.h	Mon Nov 18 22:05:42 2024 +0100
@@ -396,6 +396,74 @@
         size_t len
 );
 
+#ifdef __cplusplus
+} // extern "C"
+/**
+ * Fills the input buffer with a string.
+ *
+ * Currently unprocessed data is copied to a temporary buffer.
+ * This temporary buffer is allocated on the heap, unless you specified
+ * a buffer on the stack with #cxPropertiesUseStack().
+ * In that case, the stack buffer is used, until the capacity is not sufficient
+ * anymore.
+ *
+ * @param prop the properties interface
+ * @param str the string
+ * @return non-zero when a memory allocation was necessary but failed
+ */
+cx_attr_nonnull
+static inline int cxPropertiesFill(
+        CxProperties *prop,
+        cxstring str
+) {
+    return cxPropertiesFilln(prop, str.ptr, str.length);
+}
+
+/**
+ * Fills the input buffer with a string.
+ *
+ * Currently unprocessed data is copied to a temporary buffer.
+ * This temporary buffer is allocated on the heap, unless you specified
+ * a buffer on the stack with #cxPropertiesUseStack().
+ * In that case, the stack buffer is used, until the capacity is not sufficient
+ * anymore.
+ *
+ * @param prop the properties interface
+ * @param str the string
+ * @return non-zero when a memory allocation was necessary but failed
+ */
+cx_attr_nonnull
+static inline int cxPropertiesFill(
+        CxProperties *prop,
+        cxmutstr str
+) {
+    return cxPropertiesFilln(prop, str.ptr, str.length);
+}
+
+/**
+ * Fills the input buffer with a string.
+ *
+ * Currently unprocessed data is copied to a temporary buffer.
+ * This temporary buffer is allocated on the heap, unless you specified
+ * a buffer on the stack with #cxPropertiesUseStack().
+ * In that case, the stack buffer is used, until the capacity is not sufficient
+ * anymore.
+ *
+ * @param prop the properties interface
+ * @param str the string
+ * @return non-zero when a memory allocation was necessary but failed
+ */
+cx_attr_nonnull
+cx_attr_cstr_arg(2)
+static inline int cxPropertiesFill(
+        CxProperties *prop,
+        const char *str
+) {
+    return cxPropertiesFilln(prop, str, strlen(str));
+}
+
+extern "C" {
+#else // __cplusplus
 /**
  * Fills the input buffer with a string.
  *
@@ -461,6 +529,7 @@
 ) {
     return cxPropertiesFilln(prop, str, strlen(str));
 }
+#endif
 
 /**
  * Specifies stack memory that shall be used by #cxPropertiesFill().
--- a/src/cx/tree.h	Tue Nov 12 17:34:04 2024 +0100
+++ b/src/cx/tree.h	Mon Nov 18 22:05:42 2024 +0100
@@ -264,8 +264,8 @@
  */
 cx_attr_nonnull
 void cx_tree_link(
-        void *restrict parent,
-        void *restrict node,
+        void *parent,
+        void *node,
         ptrdiff_t loc_parent,
         ptrdiff_t loc_children,
         ptrdiff_t loc_last_child,
--- a/src/tree.c	Tue Nov 12 17:34:04 2024 +0100
+++ b/src/tree.c	Mon Nov 18 22:05:42 2024 +0100
@@ -62,8 +62,8 @@
 }
 
 void cx_tree_link(
-        void *restrict parent,
-        void *restrict node,
+        void *parent,
+        void *node,
         ptrdiff_t loc_parent,
         ptrdiff_t loc_children,
         ptrdiff_t loc_last_child,
--- a/tests/Makefile	Tue Nov 12 17:34:04 2024 +0100
+++ b/tests/Makefile	Mon Nov 18 22:05:42 2024 +0100
@@ -23,8 +23,6 @@
 
 include ../config.mk
 
-CFLAGS += -I../src
-
 TEST_DIR=$(build_dir)/tests
 
 SRC = util_allocator.c \
@@ -57,24 +55,24 @@
 $(TEST_DIR)/test_allocator$(OBJ_EXT): test_allocator.c ../src/cx/test.h \
  ../src/cx/common.h ../src/cx/allocator.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/test_buffer$(OBJ_EXT): test_buffer.c ../src/cx/test.h \
  ../src/cx/common.h util_allocator.h ../src/cx/allocator.h \
  ../src/cx/buffer.h ../src/cx/allocator.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/test_compare$(OBJ_EXT): test_compare.c ../src/cx/test.h \
  ../src/cx/common.h ../src/cx/compare.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/test_hash_key$(OBJ_EXT): test_hash_key.c ../src/cx/test.h \
  ../src/cx/common.h ../src/cx/hash_key.h ../src/cx/string.h \
  ../src/cx/allocator.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/test_hash_map$(OBJ_EXT): test_hash_map.c ../src/cx/test.h \
  ../src/cx/common.h util_allocator.h ../src/cx/allocator.h \
@@ -82,19 +80,19 @@
  ../src/cx/allocator.h ../src/cx/iterator.h ../src/cx/compare.h \
  ../src/cx/string.h ../src/cx/hash_key.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/test_iterator$(OBJ_EXT): test_iterator.c ../src/cx/test.h \
  ../src/cx/common.h ../src/cx/iterator.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/test_json$(OBJ_EXT): test_json.c ../src/cx/test.h \
  ../src/cx/common.h ../src/cx/json.h ../src/cx/string.h \
  ../src/cx/allocator.h ../src/cx/array_list.h ../src/cx/list.h \
  ../src/cx/collection.h ../src/cx/iterator.h ../src/cx/compare.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/test_list$(OBJ_EXT): test_list.c ../src/cx/test.h \
  ../src/cx/common.h util_allocator.h ../src/cx/allocator.h \
@@ -102,20 +100,20 @@
  ../src/cx/collection.h ../src/cx/allocator.h ../src/cx/iterator.h \
  ../src/cx/compare.h ../src/cx/linked_list.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/test_mempool$(OBJ_EXT): test_mempool.c ../src/cx/test.h \
  ../src/cx/common.h util_allocator.h ../src/cx/allocator.h \
  ../src/cx/mempool.h ../src/cx/allocator.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/test_printf$(OBJ_EXT): test_printf.c ../src/cx/test.h \
  ../src/cx/common.h util_allocator.h ../src/cx/allocator.h \
  ../src/cx/printf.h ../src/cx/string.h ../src/cx/allocator.h \
  ../src/cx/buffer.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/test_properties$(OBJ_EXT): test_properties.c ../src/cx/test.h \
  ../src/cx/common.h util_allocator.h ../src/cx/allocator.h \
@@ -124,39 +122,39 @@
  ../src/cx/compare.h ../src/cx/hash_key.h ../src/cx/array_list.h \
  ../src/cx/list.h ../src/cx/hash_map.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/test_streams$(OBJ_EXT): test_streams.c ../src/cx/test.h \
  ../src/cx/common.h ../src/cx/streams.h ../src/cx/buffer.h \
  ../src/cx/allocator.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/test_string$(OBJ_EXT): test_string.c ../src/cx/test.h \
  ../src/cx/common.h util_allocator.h ../src/cx/allocator.h \
  ../src/cx/string.h ../src/cx/allocator.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/test_szmul$(OBJ_EXT): test_szmul.c ../src/cx/test.h \
  ../src/cx/common.h ../src/szmul.c ../src/cx/common.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/test_tree$(OBJ_EXT): test_tree.c ../src/cx/tree.h \
  ../src/cx/common.h ../src/cx/collection.h ../src/cx/allocator.h \
  ../src/cx/iterator.h ../src/cx/compare.h ../src/cx/test.h \
  util_allocator.h ../src/cx/allocator.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/ucxtest$(OBJ_EXT): ucxtest.c ../src/cx/common.h \
  ../src/cx/test.h ../src/cx/common.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
 $(TEST_DIR)/util_allocator$(OBJ_EXT): util_allocator.c util_allocator.h \
  ../src/cx/allocator.h ../src/cx/common.h ../src/cx/test.h
 	@echo "Compiling $<"
-	$(CC) -o $@ $(CFLAGS) -c $<
+	$(CC) -o $@ $(CFLAGS) -I../src -c $<
 
--- a/tests/util_allocator.h	Tue Nov 12 17:34:04 2024 +0100
+++ b/tests/util_allocator.h	Mon Nov 18 22:05:42 2024 +0100
@@ -32,7 +32,7 @@
 #include "cx/allocator.h"
 
 #ifdef __cplusplus
-#extern "C" {
+extern "C" {
 #endif
 
 typedef struct CxTestingAllocator {

mercurial