Fix 2004/vik2 for Linux
Unfortunately this fix required heavy modification to the original file and inclusion of a file that was once generated by the Makefile but now it works for both macOS and Linux. It unfortunately will generate a lot of warnings in Linux (or at least some - in Rocky Linux and Fedora Linux it generates a lot of warnings about GCC extensions and with clang it also generates warning(s?) about reserved keywords for a total of 45131 (!!) warnings) but still it now works with Linux and macOS (clean compilation). See the thanks-for-fixes.md file for example warnings and what this fix entailed.
This commit is contained in:
1 parent
04ffb70221
commit
a836f887eb
5 files changed
+2628
-1027
No files matched your search
@@ -1,6 +1,4 @@
|
||||
cat-killing-curiosity
|
||||
vik2
|
||||
vik2_1.c
|
||||
vik2_2.c
|
||||
vik2.possible.cat.death_1.c
|
||||
vik2.possible.cat.death_2.c
|
||||
+5
-10
@@ -38,7 +38,7 @@ include ../../var.mk
|
||||
|
||||
# Common C compiler warnings to silence
|
||||
#
|
||||
CSILENCE= -Wno-strict-prototypes
|
||||
CSILENCE= -Wno-strict-prototypes -Wno-implicit-function-declaration
|
||||
|
||||
# Common C compiler warning flags
|
||||
#
|
||||
@@ -127,11 +127,7 @@ all: data ${TARGET}
|
||||
supernova deep_magic magic charon pluto
|
||||
|
||||
${PROG}: ${PROG}.c
|
||||
${RM} -f ${PROG}_1.c
|
||||
${CC} -E '-DSTOP=_5' '-DFNAME="${PROG}_1.c"' ${PROG}.c > ${PROG}_1.c
|
||||
${RM} -f ${PROG}_2.c
|
||||
${CC} -E ${PROG}_1.c > ${PROG}_2.c
|
||||
${CC} ${CFLAGS} ${PROG}_2.c -o ${PROG}
|
||||
${CC} ${CFLAGS} -DFNAME='"${PROG}.c"' '-DSTOP=_5' ${PROG}.c -o ${PROG}
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
@@ -153,12 +149,12 @@ everything: all alt
|
||||
# On some systems such as Linux, this source either fails
|
||||
# to finish compiling or takes a super-long time generating
|
||||
# a huge number of compiler errors. As such, we do not
|
||||
# recommend compiling this code. However for some the
|
||||
# recommend compiling this code. However for ailurophiles the
|
||||
# curiosity factor, even though it may have the effect of:
|
||||
#
|
||||
# kill -9 cat
|
||||
#
|
||||
# may too strong for some not try to compile the original
|
||||
# may be too strong to not try and compile the original
|
||||
# vik2 source code. Therefore we offer this special
|
||||
# Makefile rule for those who do not wish curtail their curiosity.
|
||||
#
|
||||
@@ -184,14 +180,13 @@ clean:
|
||||
${RM} -f indent.c; \
|
||||
fi
|
||||
vik2_clean:
|
||||
${RM} -f vik2_1.c vik2_2.c vik2.o
|
||||
${RM} -f vik2.o
|
||||
|
||||
vik2_clobber: vik2_clean
|
||||
${RM} -f vik2
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${TARGET} ${ALT_TARGET}
|
||||
${RM} -f ${PROG}_1.c ${PROG}_2.c
|
||||
${RM} -f ${PROG}.possible.cat.death_1.c ${PROG}.possible.cat.death_2.c cat-killing-curiosity
|
||||
@-if [ -e sandwich ]; then \
|
||||
${RM} -f sandwich; \
|
||||
|
||||
+995
-1014
File diff suppressed because it is too large.
Load diff
+1555
File diff suppressed because it is too large.
Load diff
+73
-1
@@ -958,7 +958,7 @@ int and the rest must be a `char **`.
|
||||
|
||||
## [2004/gavin](2004/gavin/gavin.c) ([README.md](2004/gavin/README.md]))
|
||||
|
||||
Yusuke provided the `kernel` and `fs.tar`
|
||||
Yusuke provided the `kernel` and `fs.tar`
|
||||
files which can be used if you cannot normally use this entry. Instead of
|
||||
generating the files just use the files provided, found under the
|
||||
[img/](2004/gavin/img/)
|
||||
@@ -982,6 +982,78 @@ second arg to main, which clang requires to be a `char **`, to be not the same
|
||||
name as a function defined earlier in the code and to use that variable which
|
||||
`main()` used.
|
||||
|
||||
## [2004/vik2](2004/vik2/vik2.c) ([README.md](2004/vik2/README.md))
|
||||
|
||||
Cody fixed this to compile in Linux. Although it compiled cleanly in macOS (and
|
||||
BSD?) the code failed to compile at all in Linux due to:
|
||||
|
||||
```c
|
||||
cc -E vik2_1.c > vik2_2.c
|
||||
In file included from vik2.c:945,
|
||||
from vik2.c:959,
|
||||
from vik2.c:972,
|
||||
from vik2.c:1025:
|
||||
vik2.c:383:8: error: no macro name given in #ifdef directive
|
||||
383 | O \
|
||||
| ^
|
||||
In file included from vik2.c:946:
|
||||
vik2.c:383:8: error: no macro name given in #ifdef directive
|
||||
383 | O \
|
||||
| ^
|
||||
In file included from vik2.c:947:
|
||||
vik2.c:383:8: error: no macro name given in #ifdef directive
|
||||
383 | O \
|
||||
| ^
|
||||
In file included from vik2.c:948:
|
||||
vik2.c:383:8: error: no macro name given in #ifdef directive
|
||||
383 | O \
|
||||
| ^
|
||||
|
||||
...
|
||||
|
||||
In file included from vik2.c:182:
|
||||
|
||||
vik2.c:992:85: error: #include nested depth 201 exceeds maximum of 200 (use -fmax-include-depth=DEPTH to increase the maximum)
|
||||
992 | I
|
||||
| ^
|
||||
vik2.c:1497:21: error: #include nested depth 200 exceeds maximum of 200 (use -fmax-include-depth=DEPTH to increase the maximum)
|
||||
vik2.c:1498:21: error: #include nested depth 200 exceeds maximum of 200 (use -fmax-include-depth=DEPTH to increase the maximum)
|
||||
vik2.c:1499:21: error: #include nested depth 200 exceeds maximum of 200 (use -fmax-include-depth=DEPTH to increase the maximum)
|
||||
vik2.c:1500:21: error: #include nested depth 200 exceeds maximum of 200 (use -fmax-include-depth=DEPTH to increase the maximum)
|
||||
vik2.c:1501:21: error: #include nested depth 200 exceeds maximum of 200 (use -fmax-include-depth=DEPTH to increase the maximum)
|
||||
vik2.c:1504:21: error: #include nested depth 200 exceeds maximum of 200 (use -fmax-include-depth=DEPTH to increase the maximum)
|
||||
make: *** [Makefile:133: vik2] Error 1
|
||||
|
||||
```
|
||||
|
||||
Unfortunately the fix required heavy modification to the original file (see
|
||||
below) and also inclusion of what used to be generated by the
|
||||
[Makefile](2004/vik2/Makefile) and will, in Linux, give many warnings like:
|
||||
|
||||
```c
|
||||
cc -std=gnu99 -Wall -Wextra -pedantic -Wno-strict-prototypes -Wno-implicit-function-declaration -O3 -DFNAME='"vik2.c"' '-DSTOP=_5' vik2.c -o vik2
|
||||
In file included from vik2.c:1002:
|
||||
vik2_1.c: In function 'main':
|
||||
vik2_1.c:1:3: warning: style of line directive is a GCC extension
|
||||
1 | # 1 "vik2.c"
|
||||
| ^
|
||||
|
||||
...
|
||||
|
||||
```
|
||||
|
||||
(which does not show up in macOS) but now it at least works for both Linux and
|
||||
macOS.
|
||||
|
||||
As for the fix itself it required changing the C pre-processor macros that
|
||||
resulted in macros themselves like `#ifdef`, `#else` etc. to be `#ifdef`,
|
||||
`#else` etc. and also the inclusion of the file [vik2_1.c](2004/vik2/vik2_1.c)
|
||||
which used to be generated by the Makefile via `cc -E`. As one can see that file
|
||||
has references to macOS things but this is not harmful in Linux. It might be
|
||||
that those lines can be removed but there is no harm and since there are a lot
|
||||
of it this has not been done (`vik2.c` has 1009 lines and `vik2_1.c` has 1555
|
||||
lines!).
|
||||
|
||||
|
||||
## [2005/aidan](2005/aidan/aidan.c) ([README.md](2005/aidan/README.md]))
|
||||
|
||||
|
||||
Reference in new issue
Block a user