From 3f2b5097e943762445b3f54d05ef73076a69ddbc Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Thu, 27 Apr 2023 03:41:31 -0700 Subject: [PATCH] Fixes in 1984/decot Updated fixes in README in a better order (not chronological but in a way that shows how it shows that I fixed it to not require -traditional-cpp and also fixed the type of args in main() that clang enforces). The fix by Yusuke Endoh which only let it compile with gcc (with -traditional-cpp) is below that. To the cynics: this is not because I want my fix at the top but rather that my fixes make it more portable which makes it easier to use. With my fix the other one is not technically even needed but I want to give thanks anyway as he contributed to it (albeit without knowing about it yet). Fixed make alt rule so that it uses -traditional-cpp as it needs it. This code will not work with clang because it doesn't support that option and it has the type of main() args issue. That means it won't work with macOS default compiler even gcc. --- 1984/decot/Makefile | 3 +++ 1984/decot/README.md | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/1984/decot/Makefile b/1984/decot/Makefile index 9eb6160d8..d6709ab28 100644 --- a/1984/decot/Makefile +++ b/1984/decot/Makefile @@ -137,6 +137,9 @@ ${PROG}: ${PROG}.c alt: data ${ALT_TARGET} @${TRUE} + +${PROG}.alt: ${PROG}.alt.c + ${CC} ${CFLAGS} -traditional-cpp $< -o $@ ${LIBS} # data files # data: ${DATA} diff --git a/1984/decot/README.md b/1984/decot/README.md index d57e29362..ed0215d26 100644 --- a/1984/decot/README.md +++ b/1984/decot/README.md @@ -8,14 +8,16 @@ Dave Decot make all ``` +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to not +require `-traditional-cpp` which not all compilers support (clang does not +support it for example). Clang is also more strict about the args' types in +`main()` and this was also a problem that Cody fixed, making it work with both +clang and gcc. For the original code with the gcc fix described below, see the +alternate code section below. Thank you Cody for your assistance! + Originally [Yusuke Endoh](/winners.html#Yusuke_Endoh) supplied a patch so that this entry would compile with gcc - but not clang - or at least some versions. -Thank you Yusuke! [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) -noticed this did not work under fedora linux and it definitely didn't work with -macOS as it required a compiler that supports `-traditional-cpp` which clang -does not. Clang also requires that the second and third arguments to main be a -`char **`. Cody fixed both problems and now it works under both macOS and linux -- clang and gcc. Thank you Cody for your assistance! +Thank you Yusuke! ## To run: @@ -23,9 +25,9 @@ does not. Clang also requires that the second and third arguments to main be a ./decot ``` -### Alternative code: +### Alternate code: -The alternative code, [decot.alt.c](decot.alt.c), is the original code that +The alternate code, [decot.alt.c](decot.alt.c), is the original code that requires `-traditional-cpp` and will also run afoul with clang's requirement for the second and third arguments to main() being a `char **` (the fixed version's main() only has one arg, an int). It is a minor fix to Yusuke's fix. Thank you