diff --git a/1984/decot/Makefile b/1984/decot/Makefile index a4d88b4e0..9eb6160d8 100644 --- a/1984/decot/Makefile +++ b/1984/decot/Makefile @@ -63,7 +63,7 @@ CDEFINE= # Include files that are needed to compile # -CINCLUDE= +CINCLUDE= -include stdio.h -include math.h # Optimization # @@ -75,7 +75,7 @@ CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT} # Libraries needed to build # -LIBS= +LIBS= -lm # C compiler to use # @@ -114,12 +114,8 @@ OBJ= ${PROG}.o DATA= TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= - -# FORCE use of -traditional-cpp -# -CFLAGS+= -traditional-cpp +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# @@ -134,7 +130,6 @@ all: data ${TARGET} supernova deep_magic magic charon pluto ${PROG}: ${PROG}.c - @echo "NOTE: this entry requires a compiler that supports -traditional-cpp." ${CC} ${CFLAGS} $< -o $@ ${LIBS} # alternative executable diff --git a/1984/decot/README.md b/1984/decot/README.md index 5d6fa6774..a426ea77e 100644 --- a/1984/decot/README.md +++ b/1984/decot/README.md @@ -6,33 +6,63 @@ Dave Decot make all -[Yusuke Endoh](/winners.html#Yusuke_Endoh) supplied a patch so that this -entry would compile with gcc. Thank you Yusuke! - -NOTE: this entry requires a compiler that supports `-traditional-cpp`. Note that -clang does not support it and in macOS gcc is actually clang so this will not -compile with the default compiler in macOS. +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 requires 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! ## To run: - ./decot +```sh +./decot +``` + +### Alternative code: + +The alternative code, [decot.alt.c](decot.alt.c), is the fix that Cody made to +the version that does require `-traditional-cpp` and still runs 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 Yusuke and Cody! + +To try this version: + +```sh +make alt +./decot.alt +``` + ## Judges' comments: - -Some new (in 1984) compilers disliked line 15 of the source, so we changed it -from: - - for(signal=0;*k * x * __FILE__ *i;) do { - -to: - - for(signal=0;*k *x * __FILE__ *i;) do { - This program prints out a string of garbage. The judges also offer this one comment: understand comments! +### Historical comments: + +Some new (in 1984) compilers disliked line 15 of the original source, so we changed it +from: + +```c +for(signal=0;*k * x * __FILE__ *i;) do { +``` + +to: + +```c +for(signal=0;*k *x * __FILE__ *i;) do { +``` + + +To see what we mean look at the source file in the +[archive/archive-1984.tar.bz2](/archive-1984.tar.bz2) tarball or +[decot.alt.c](decot.alt.c). + ## Author's comments: No comments were provided by the author. diff --git a/1984/decot/decot.alt.c b/1984/decot/decot.alt.c new file mode 100644 index 000000000..ad6135edc --- /dev/null +++ b/1984/decot/decot.alt.c @@ -0,0 +1,33 @@ +int printf(const char *format, ...); +double floor(double x); +#define x = +#define double(a,b) int +#define char k['a'] +#define union static struct + +double (x1, y1) b, +char x {sizeof( + double(%s,%D)(*)()) +,}; +struct tag{int x0,*xO;} + +*main(i, dup, signal) { +{ + for(signal=0;*k *x * __FILE__ *i;) do { + (printf(&*"'\",x); /*\n\\", (*((double(tag,u)(*)())&floor))(i))); + goto _0; + +_O: while (!(char < xO));/*} + ; +} + +*/}}} diff --git a/1984/decot/decot.c b/1984/decot/decot.c index 61b97e3f6..10101a4e8 100644 --- a/1984/decot/decot.c +++ b/1984/decot/decot.c @@ -1,30 +1,26 @@ -#define x = -#define double(a,b) int -#define char k['a'] -#define union static struct - -double (x1, y1) b, -char x {sizeof( - double(%s,%D)(*)()) +int b, +k['a'] = {sizeof( + int(*)()) ,}; -struct tag{int x0,*xO;} +struct tag{int x0,*xO;}; -*main(i, dup, signal) { +int dup, signal; +*main(int i) { { - for(signal=0;*k *x * __FILE__ *i;) do { - (printf(&*"'\",x); /*\n\\", (*((double(tag,u)(*)())&floor))(i))); + for(signal=0;*k *= * __FILE__ *i;) do { + (printf(&*"'\",x); /*\n\\", (*((int(*)())&floor))(i))); goto _0; -_O: while (!(char < xO));/*} +sin(signal) / * ((main) (((struct tag *)b)-> xO)));/*} ; } diff --git a/bugs.md b/bugs.md index d79c7e89b..3e8d4c6f2 100644 --- a/bugs.md +++ b/bugs.md @@ -245,19 +245,6 @@ this in the [README.md](1984/anonymous/README.md) file. Can you fix this? We welcome your help! -## [1984/decot](1984/decot/decot.c) ([README.md](1984/decot/README.md)) -## STATUS: requires a compiler supporting `-traditional-cpp` - alternate code requested - -This entry needs a compiler that support `-traditional-cpp`. `gcc` -supports this but `clang` does not. Please be advised that `gcc` under macOS is -actually gcc if it looks like it's gcc (two different binaries). - -If you do wish to provide an alternate version of the program that does not need -compiler supporting `-traditional-cpp` you are welcome to submit such code via a [GitHub pull request](https://github.com/ioccc-src/temp-test-ioccc/pulls) and we will be happy to credit you in the entry's _README.md_ file. - - -# 1984 - # 1985