Add 1988/spinellis/spinellis.alt.c for clang
This was fun to do even though it's also a very simple one liner plus
special handling in the Makefile (the latter part is so you can use it
the exact same way as the original). The original code just #included
/dev/tty. This does something just as magical! It can be used like:
make alt
# some C code
^D
./spinellis
For instance:
make alt
#include <stdio.h>
int main() { puts("hello world"); }
^D
./spinellis
Now those with clang can enjoy the entry without any functional
difference.
I have a very twisted point to make about the original version and this
version too: with a very slight change one can actually make a C++
version. Ick! :-)
This commit is contained in:
1 parent
ee249da4ea
commit
6e206fc25a
4 files changed
+36
-14
No files matched your search
@@ -1,2 +1,3 @@
|
|||||||
prog.c
|
prog.c
|
||||||
spinellis
|
spinellis
|
||||||
|
spinellis.alt
|
||||||
@@ -111,8 +111,8 @@ OBJ= ${PROG}.o
|
|||||||
DATA= spinellis.data
|
DATA= spinellis.data
|
||||||
TARGET= ${PROG}
|
TARGET= ${PROG}
|
||||||
#
|
#
|
||||||
ALT_OBJ=
|
ALT_OBJ= ${PROG}.alt.o
|
||||||
ALT_TARGET=
|
ALT_TARGET= ${PROG}.alt
|
||||||
|
|
||||||
|
|
||||||
#################
|
#################
|
||||||
@@ -135,6 +135,10 @@ ${PROG}: ${PROG}.c
|
|||||||
alt: data ${ALT_TARGET}
|
alt: data ${ALT_TARGET}
|
||||||
@${TRUE}
|
@${TRUE}
|
||||||
|
|
||||||
|
${PROG}.alt: ${PROG}.alt.c
|
||||||
|
${CC} ${CFLAGS} -Wno-implicit-function-declaration $< -o $@ ${LIBS}
|
||||||
|
@while read -r r; do echo $$r ; done | ./${PROG}.alt
|
||||||
|
|
||||||
# data files
|
# data files
|
||||||
#
|
#
|
||||||
data: ${DATA}
|
data: ${DATA}
|
||||||
|
|||||||
+28
-12
@@ -10,11 +10,11 @@
|
|||||||
|
|
||||||
make all
|
make all
|
||||||
|
|
||||||
and then type a C program into followed by EOF two times (`^D^D`).
|
and then type a C program into followed by EOF (usually `^D`, ctrl-d).
|
||||||
|
|
||||||
NOTE: this entry will not compile with clang. Also be advised that gcc in macOS
|
|
||||||
is actually clang so this will not work even with the default compiler in macOS.
|
|
||||||
|
|
||||||
|
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made a version (also
|
||||||
|
one-line) for clang. See the alternative code section below for how to use.
|
||||||
|
Thank you Cody for your assistance!
|
||||||
|
|
||||||
## Try:
|
## Try:
|
||||||
|
|
||||||
@@ -35,23 +35,39 @@ is actually clang so this will not work even with the default compiler in macOS.
|
|||||||
printf("%d\n", i);
|
printf("%d\n", i);
|
||||||
}
|
}
|
||||||
^D
|
^D
|
||||||
|
./spinellis
|
||||||
|
|
||||||
|
## Alternative code:
|
||||||
|
|
||||||
|
For clang try the alt code like:
|
||||||
|
|
||||||
|
make clobber alt
|
||||||
|
#include <stdio.h>
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
puts("Hello world\n");
|
||||||
|
}
|
||||||
^D
|
^D
|
||||||
./spinellis
|
./spinellis
|
||||||
|
|
||||||
|
|
||||||
## Judges' comments
|
|
||||||
|
## Judges' comments:
|
||||||
|
|
||||||
We enjoyed this entry this year, however in the future programs must be able to
|
We enjoyed this entry this year, however in the future programs must be able to
|
||||||
be compiled from within a Makefile without the need of human intervention.
|
be compiled from within a Makefile without the need of human intervention.
|
||||||
|
|
||||||
The author originally wrote:
|
Meanwhile Cody was twisted enough to point out (though to be fair he felt sick
|
||||||
|
doing this) that with a slight modification this entry can be C++ instead. We don't
|
||||||
|
thank him for this ghastly point! :-)
|
||||||
|
|
||||||
This program can be configured to do almost everything.
|
## Author's comments:
|
||||||
The configuration is done during compile time by typing
|
|
||||||
in, C code, that one would like the program to perform.
|
This program can be configured to do almost everything. The configuration is
|
||||||
A trivial example is given in the `how to compile' section
|
done during compile time by typing in, C code, that one would like the program
|
||||||
but the possibilities are clearly limited only by your
|
to perform. A trivial example is given in the `how to compile' section but the
|
||||||
imagination and programming skills.
|
possibilities are clearly limited only by your imagination and programming
|
||||||
|
skills.
|
||||||
|
|
||||||
## Copyright and CC BY-SA 4.0 License:
|
## Copyright and CC BY-SA 4.0 License:
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
main(){system("gcc -x c - -o spinellis");}
|
||||||
Reference in new issue
Block a user