Add 1994/imc/try.sh + inclusion of unistd.h
The inclusion of unistd.h is for getpid(2). While not strictly necessary (at least not observed) this type of thing can be a problem and in some other entries a missing or incorrect prototype caused the entry to fail (sometimes only some systems namely macOS). This was just noticed by chance and I did it on a whim.
This commit is contained in:
1 parent
5c9d422000
commit
a438eb468f
5 files changed
+55
-8
No files matched your search
+1
-2
@@ -38,8 +38,7 @@ include ../../var.mk
|
||||
|
||||
# Common C compiler warnings to silence
|
||||
#
|
||||
CSILENCE= -Wno-error -Wno-implicit-function-declaration \
|
||||
-Wno-deprecated-non-prototype -Wno-strict-prototypes
|
||||
CSILENCE= -Wno-error -Wno-deprecated-non-prototype -Wno-strict-prototypes
|
||||
|
||||
# Common C compiler warning flags
|
||||
#
|
||||
|
||||
+1
-6
@@ -17,12 +17,7 @@ where `[NUMBER]` is an optional number. Default is 5.
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./imc 3
|
||||
./imc 3
|
||||
./imc 4
|
||||
./imc 4
|
||||
./imc 6
|
||||
./imc 13
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<unistd.h>
|
||||
#define f (sizeof(int))
|
||||
|
||||
int i,j,k,l,m,*t,*u,*v;
|
||||
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 1994/imc
|
||||
#
|
||||
|
||||
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
|
||||
# this way allows us to have the user specify a different compiler in an easy
|
||||
# way.
|
||||
if [[ -z "$CC" ]]; then
|
||||
CC="cc"
|
||||
fi
|
||||
|
||||
make CC="$CC" all >/dev/null || exit 1
|
||||
|
||||
imc()
|
||||
{
|
||||
if [[ "$#" != 1 ]]; then
|
||||
echo "$0: imc() expects 1, arg got: $#" 1>&2
|
||||
return
|
||||
fi
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./imc $1: "
|
||||
echo 1>&2
|
||||
./imc "$1"
|
||||
echo 1>&2
|
||||
|
||||
# Notice how we run the program with the same arg as above. This is because it
|
||||
# will not show the same output as it is randomised.
|
||||
read -r -n 1 -p "Press any key to run: ./imc $1: "
|
||||
echo 1>&2
|
||||
./imc "$1"
|
||||
echo 1>&2
|
||||
}
|
||||
|
||||
# clear screen after compilation so that only the entry is shown
|
||||
clear
|
||||
|
||||
imc 3
|
||||
imc 4
|
||||
imc 6
|
||||
imc 13
|
||||
imc 15
|
||||
@@ -1890,6 +1890,16 @@ newsletter was found on the Internet Wayback Machine and the article was
|
||||
extracted as a PDF in the macOS `Preview.app` (`File -> Print` feature).
|
||||
|
||||
|
||||
## <a name="1994_imc"></a>[1994/imc](/1994/imc/imc.c) ([README.md](/1994/imc/README.md]))
|
||||
|
||||
[Cody](#cody) added the [try.sh](/1994/imc/try.sh) script.
|
||||
|
||||
Cody also added inclusion of `unistd.h` for `getpid(2)`. While strictly speaking
|
||||
this was not necessary (in multiple systems) it can sometimes be a problem and
|
||||
as it was noticed it was changed (the only case this was done except in the
|
||||
entries that actually did not work because of missing or incorrect prototypes).
|
||||
|
||||
|
||||
## <a name="1994_ldb"></a>[1994/ldb](/1994/ldb/ldb.c) ([README.md](/1994/ldb/README.md]))
|
||||
|
||||
[Cody](#cody) fixed this so it would compile and work with modern compilers. The problem
|
||||
|
||||
Reference in new issue
Block a user