diff --git a/Makefile b/Makefile index 813edb28..19dfe403 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ endif CFLAGS ?= -std=c11 -Iinclude -MMD -O3 -Wpedantic -Wall -Wextra -Werror -Wno-missing-field-initializers CXXFLAGS ?= -std=c++20 -Iinclude -O3 -MMD -Wall LDFLAGS ?= -ifeq ($(CC:.exe=),tcc) +ifeq ($(CC),tcc) AR_RCS ?= tcc -ar rcs else AR_RCS ?= ar rcs @@ -24,11 +24,14 @@ RM_F ?= rm -f ifeq ($(OS),Windows_NT) DOTEXE := .exe - BUILDDIR := bld_Windows/$(CC:.exe=) + BUILDDIR := bld_Windows/$(CC) else +# CC_VER := $(shell $(CC) -dumpversion | cut -f1 -d.) BUILDDIR := bld_$(shell uname)/$(CC) LDFLAGS += -lm - CFLAGS += -Wno-clobbered + ifneq ($(CC),clang) + CFLAGS += -Wno-clobbered + endif endif OBJ_DIR := $(BUILDDIR) @@ -50,10 +53,15 @@ TEST_OBJS := $(TEST_SRCS:%.c=$(OBJ_DIR)/%.o) TEST_DEPS := $(TEST_SRCS:%.c=$(OBJ_DIR)/%.d) TEST_EXE := $(OBJ_DIR)/tests/test_all$(DOTEXE) +PROGRAMS := $(EX_EXES) $(TEST_EXE) + fast: @$(MAKE) -j --no-print-directory all -all: $(LIB_PATH) $(EX_EXES) $(TEST_EXE) +all: $(PROGRAMS) + @echo + +$(PROGRAMS): $(LIB_PATH) clean: @$(RM_F) $(LIB_OBJS) $(TEST_OBJS) $(EX_OBJS) $(LIB_DEPS) $(EX_DEPS) $(LIB_PATH) $(EX_EXES) $(TEST_EXE) @@ -85,6 +93,7 @@ $(OBJ_DIR)/%$(DOTEXE): %.c $(LIB_PATH) $(TEST_EXE): $(TEST_OBJS) @printf "\r\e[2K%s" "$(CC) -o $@" + @echo @$(CC) -o $@ $(TEST_OBJS) -s $(LDFLAGS) -L$(BUILDDIR) -l$(LIB_NAME) diff --git a/docs/algorithm_api.md b/docs/algorithm_api.md index 35800890..9697ee2e 100644 --- a/docs/algorithm_api.md +++ b/docs/algorithm_api.md @@ -257,8 +257,12 @@ The **c_when** statement is exhaustive. The compiler will give a warning if not covered by **c_is** (requires `-Wall` or `-Wswitch` gcc/clang compiler flag). The first enum value is deliberately set to 1 in order to easier detect non/zero-initialized variants. -* Note 1: The `x` variables in the synopsis are "auto" type declared/defined - see examples. -* Note 2: Sum types will not work in coroutines (i.e. if `cco_yield..` or `cco_await..` are used within `c_when` / `c_if_is` blocks). +* Note: The `x` variables in the synopsis are "auto" type declared/defined - see examples. +* Caveat 1: The use of `continue` inside a `c_when` (or `c_if_is`) block, when `c_when` is inside a loop will +not work as expected. It will only break out of the `c_when`-block. Instead, use `goto` to jump to the +end of the loop. `break` will break out of `c_when`, i.e. it behaves like `switch`. +* Caveat 2: Sum types will generally not work in coroutines because the `x` variable is local and therefore +will not be preserved across `cco_yield..` / `cco_await..`. ### Example 1 diff --git a/docs/box_api.md b/docs/box_api.md index 649a61fa..70f1e805 100644 --- a/docs/box_api.md +++ b/docs/box_api.md @@ -6,8 +6,8 @@ and `i_keydrop` macros specified. Use *box_X_clone(p)* to make a deep copy, whic `i_keyclone` macro if defined. Note that a box set to NULL is consider uninitialized, and cannot be e.g. cloned or dropped. -When declaring a container of **box** values, define `i_keypro` with the -box type instead of defining `i_key`. This will auto-set `i_keydrop`, `i_keyclone`, and `i_cmp` using +When declaring a container of **box** elements, define `i_keypro` with the +box type instead of defining `i_key`. This will auto-define `i_keydrop`, `i_keyclone`, and `i_cmp` using functions defined by the specified **box**. See similar c++ class [std::unique_ptr](https://en.cppreference.com/w/cpp/memory/unique_ptr) for a functional reference, or Rust [std::boxed::Box](https://doc.rust-lang.org/std/boxed/struct.Box.html) @@ -37,8 +37,6 @@ See similar c++ class [std::unique_ptr](https://en.cppreference.com/w/cpp/memory #define i_keyfrom // from-raw func. #include "stc/box.h" ``` -When defining a container with **box** elements, specify `#define i_keypro ` instead of `i_key`. - In the following, `X` is the value of `i_key` unless `i_type` is defined. Unless `c_use_cmp` is defined, comparison between i_key's is not needed/available. Will then compare the pointer addresses when used. Additionally, `c_no_clone` or `i_is_fwd` may be defined.