From d9e2ca04c56c4ee61dad157a55a1ff181496d222 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sat, 9 Dec 2023 18:59:53 +0000 Subject: [PATCH] document compiler warnings --- README.md | 7 ++++++- examples/core/makefile | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ac8755d..2234c59 100644 --- a/README.md +++ b/README.md @@ -284,7 +284,12 @@ In fact, squiggle.c does have a few functions for algebraic manipulations of sim #### Harsh compilation -By default, I've enabled -Warn-all, -Warn-extra. However, these produce warnings for unused variables, some of which can sometimes be inocuous. For now, I'm suppressing these using a clever UNUSED macro. If you don't like that approach, you could add -Wno-unused-parameter to your makefile and remove the macro. +By default, I've enabled -Wall -Wextra -Wdouble-promotion -Wconversion. However, these produce some false positive warnings, which I've dealt with through: + +- For conversion: Explit casts, particularly from int to size_t when calling malloc. +- For dealing with unused variables: Using an UNUSED macro. If you don't like that approach, you could add -Wno-unused-parameter to your makefile and remove the macro and its usage. + +Some ressources on compiler flags: [1](https://nullprogram.com/blog/2023/04/29/), [2](https://news.ycombinator.com/item?id=7371806) #### Results of running clang-tidy diff --git a/examples/core/makefile b/examples/core/makefile index 6fbd39a..7f6761f 100644 --- a/examples/core/makefile +++ b/examples/core/makefile @@ -22,9 +22,9 @@ MATH=-lm DEPS=$(SQUIGGLE) $(MATH) ## Flags -# DEBUG=-fsanitize=address,undefined +# DEBUG=-fsanitize=address,undefined -fanalyzer # DEBUG=-g -DEBUG= +# DEBUG= WARN=-Wall -Wextra -Wdouble-promotion -Wconversion STANDARD=-std=c99 OPTIMIZED=-O3 #-Ofast