squiggle.c

Self-contained Monte Carlo estimation in C99
Log | Files | Refs | README

commit d9e2ca04c56c4ee61dad157a55a1ff181496d222
parent 9cda19cbb52be124802f089f7b35f636e5e1d14c
Author: NunoSempere <nuno.sempere@protonmail.com>
Date:   Sat,  9 Dec 2023 18:59:53 +0000

document compiler warnings

Diffstat:
MREADME.md | 7++++++-
Mexamples/core/makefile | 4++--
2 files changed, 8 insertions(+), 3 deletions(-)

diff --git 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 @@ -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