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:
Cody Boone Ferguson committed 2023-03-27 08:59:03 -07:00
1 parent ee249da4ea
commit 6e206fc25a
4 files changed
+36 -14

No files matched your search

+1
View File
@@ -1,2 +1,3 @@
prog.c
spinellis
spinellis.alt
+6 -2
View File
@@ -111,8 +111,8 @@ OBJ= ${PROG}.o
DATA= spinellis.data
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ${PROG}.alt
#################
@@ -135,6 +135,10 @@ ${PROG}: ${PROG}.c
alt: data ${ALT_TARGET}
@${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: ${DATA}
+28 -12
View File
@@ -10,11 +10,11 @@
make all
and then type a C program into followed by EOF two times (`^D^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.
and then type a C program into followed by EOF (usually `^D`, ctrl-d).
[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:
@@ -35,23 +35,39 @@ is actually clang so this will not work even with the default compiler in macOS.
printf("%d\n", i);
}
^D
./spinellis
## Alternative code:
For clang try the alt code like:
make clobber alt
#include <stdio.h>
main()
{
puts("Hello world\n");
}
^D
./spinellis
## Judges' comments
## Judges' comments:
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.
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.
The configuration is done during compile time by typing
in, C code, that one would like the program to perform.
A trivial example is given in the `how to compile' section
but the possibilities are clearly limited only by your
imagination and programming skills.
## Author's comments:
This program can be configured to do almost everything. The configuration is
done during compile time by typing in, C code, that one would like the program
to perform. A trivial example is given in the `how to compile' section but the
possibilities are clearly limited only by your imagination and programming
skills.
## Copyright and CC BY-SA 4.0 License:
+1
View File
@@ -0,0 +1 @@
main(){system("gcc -x c - -o spinellis");}