From 76b7f121d58293f4828b58fe77561c27bad1827b Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 7 Jul 2023 10:22:38 -0700 Subject: [PATCH 1/4] Fix 2019/dogon/Makefile for clang in linux --- 2019/dogon/Makefile | 4 ++-- thanks-for-fixes.md | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/2019/dogon/Makefile b/2019/dogon/Makefile index 2ec91e0a7..fb21b973d 100644 --- a/2019/dogon/Makefile +++ b/2019/dogon/Makefile @@ -41,7 +41,7 @@ include ../../var.mk CSILENCE= -Wno-bitwise-conditional-parentheses -Wno-bitwise-op-parentheses \ -Wno-deprecated-declarations -Wno-format -Wno-parentheses \ -Wno-shift-op-parentheses -Wno-sign-compare -Wno-unused-variable \ - -Wno-main-return-type -Wno-return-type -Wno-unused-parameter + -Wno-main-return-type -Wno-return-type -Wno-unused-parameter -Wno-implicit-function-declaration # Common C compiler warning flags # @@ -64,7 +64,7 @@ CDEFINE= -DX=1280l -DY=1024l -DZ=0x20000000 # Include files that are needed to compile # -CINCLUDE= -I ${X11_INCDIR} -I ${X11_INCDIR}/X11 +CINCLUDE= -include stdio.h -I ${X11_INCDIR} -I ${X11_INCDIR}/X11 # Optimization # diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 5e998a688..edc60486a 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1443,6 +1443,7 @@ might as well. Cody added explicit linking of libm (`-lm`) for systems that do not do this (linux does not seem to but macOS does). +He also fixed the Makefile so that it compiles with clang in linux. ## [2019/karns](2019/karns/prog.c) ([README.md](2019/karns/README.md])) From 29889fe686a41f31c367f43c3f8215a7dcaf4804 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 7 Jul 2023 10:36:02 -0700 Subject: [PATCH 2/4] Fix 1994/ldb for clang in linux It objected to the incompatible pointer type passed to time(2) as what was passed to time(2) was an int, not a time_t *. One way would be to disable the warning but I chose to cast the parameter to a time_t * to get rid of the warning wanting to be triggered at all. --- 1994/ldb/Makefile | 2 +- 1994/ldb/ldb.c | 2 +- thanks-for-fixes.md | 21 +++++++++++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/1994/ldb/Makefile b/1994/ldb/Makefile index 1b8d8425f..09ddf4d3b 100644 --- a/1994/ldb/Makefile +++ b/1994/ldb/Makefile @@ -38,7 +38,7 @@ include ../../var.mk # Common C compiler warnings to silence # -CSILENCE= -Wno-trigraphs +CSILENCE= -Wno-trigraphs -Wno-int-conversion # Common C compiler warning flags # diff --git a/1994/ldb/ldb.c b/1994/ldb/ldb.c index b219ce3ca..01ed9498b 100644 --- a/1994/ldb/ldb.c +++ b/1994/ldb/ldb.c @@ -1 +1 @@ -int _,O,__??('}'??);main(){while(O?(fgets((rand()%O++?':':_)+__,232,stdin))||puts(&__??(_??))&_:(srand(time((O+++_))),0)||O);} +int _,O,__??('}'??);main(){while(O?(fgets((rand()%O++?':':_)+__,232,stdin))||puts(&__??(_??))&_:(srand(time((time_t *)(O+++_))),0)||O);} diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index edc60486a..d65c9a16d 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -604,14 +604,19 @@ which main() calls with the right parameters. Cody fixed this so it would compile and work with modern compilers. The problem was that `srand()` returns void but it was used in a `||` expression. Thus the -comma operator was needed. Cody also changed the entry to use `fgets()` instead -of `gets()` to make it safe for lines greater than 231 in length and to prevent -a warning at linking or at runtime, the latter of which can be interspersed with -output of the program. Note that this now prints a newline after the output but -this seems like a worthy compromise for making the output incorrect in macOS and -at the same time it's safer (fixing it to not have the extra newline is more -problematic than it's worth and in macOS another line of output would be shown -anyway). +comma operator was needed. + +Cody also fixed it for clang under linux which objected to incompatible pointer +type (because `time(2)` takes a `time_t *` which in some systems is a `long *` +but what was being passed to it is an `int`). + +Cody also changed the entry to use `fgets()` instead of `gets()` to make it safe +for lines greater than 231 in length and to prevent a warning at linking or at +runtime, the latter of which can be interspersed with output of the program. +Note that this now prints a newline after the output but this seems like a +worthy compromise for making the output incorrect in macOS and at the same time +it's safer (fixing it to not have the extra newline is more problematic than +it's worth and in macOS another line of output would be shown anyway). A subtlety about this fix: if a line is greater than 231 in length if the program chooses that line it might print the first 231 characters or it might From 2d326bd53b3fab4f50ef4c6274eacb34d26c6c6d Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 7 Jul 2023 10:41:31 -0700 Subject: [PATCH 3/4] Fix 1989/ovdluhe/Makefile for clang in linux Makefile:90: *** recipe commences before first target. Stop. This happened due to a typo which left off a \ before a newline where it is meant to be one line. --- 1989/ovdluhe/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1989/ovdluhe/Makefile b/1989/ovdluhe/Makefile index 34f9f9ef7..940fe1c0f 100644 --- a/1989/ovdluhe/Makefile +++ b/1989/ovdluhe/Makefile @@ -86,7 +86,7 @@ CC= cc ifeq ($(CC),clang) # CSILENCE+= -Wno-comma -Wno-implicit-int-conversion -Wno-missing-prototypes \ - -Wno-missing-variable-declarations -Wno-poison-system-directories + -Wno-missing-variable-declarations -Wno-poison-system-directories \ -Wno-sign-conversion -Wno-strict-prototypes # CWARN+= -Weverything From 7a96697c4c991b169644e7b1c7de1f04923d2468 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 7 Jul 2023 10:47:11 -0700 Subject: [PATCH 4/4] Fix 1990/theorem/Makefile for clang in linux Disabled a warning that defaulted to an error. In this case it was easier to do it this way due to the way the entry works. --- 1990/theorem/Makefile | 2 +- thanks-for-fixes.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/1990/theorem/Makefile b/1990/theorem/Makefile index bc35188b9..0afb8d29f 100644 --- a/1990/theorem/Makefile +++ b/1990/theorem/Makefile @@ -41,7 +41,7 @@ include ../../var.mk CSILENCE= -Wno-deprecated-declarations -Wno-empty-body -Wno-error -Wno-unused-value \ -Wno-implicit-function-declaration -Wno-incompatible-pointer-types \ -Wno-macro-redefined -Wno-parentheses -Wno-return-type -Wno-unused-parameter \ - -Wno-empty-translation-unit + -Wno-empty-translation-unit -Wno-int-conversion # Common C compiler warning flags # diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index d65c9a16d..1949c0779 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -424,6 +424,10 @@ and to prevent a warning about `gets()` at linking or runtime. Since this program is so incredible the extra fixes were deemed worth having and this is why it was done. +Cody disabled a warning in the Makefile that proved to be a problem only with +clang in linux but which was defaulting to an error. This way was the simplest +way to deal with the problem in question due to the way the entry works. + Yusuke pointed out that `atof` nowadays needs `#include ` which was used in order to get this to work initially (prior to this output was there but incomplete).