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.
This commit is contained in:
Cody Boone Ferguson committed 2023-04-27 03:41:31 -07:00
1 parent ea12d56f72
commit 3f2b5097e9
2 files changed
+13 -8

No files matched your search

+3
View File
@@ -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}
+10 -8
View File
@@ -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