Merge pull request #1156 from xexyl/2006-sloane-clang-defect-fix
Fix 2006/sloane for some versions of clang
This commit is contained in:
5 files changed
+25
-17
No files matched your search
@@ -40,7 +40,7 @@ include ../../var.mk
|
||||
#
|
||||
CSILENCE= -Wno-error -Wno-implicit-function-declaration -Wno-implicit-int \
|
||||
-Wno-pedantic -Wno-return-type -Wno-shift-op-parentheses -Wno-unsequenced \
|
||||
-Wno-deprecated-non-prototype -Wno-main
|
||||
-Wno-deprecated-non-prototype -Wno-main -Wno-unused-parameter
|
||||
|
||||
# Common C compiler warning flags
|
||||
#
|
||||
@@ -59,7 +59,7 @@ ARCH=
|
||||
|
||||
# Defines that are needed to compile
|
||||
#
|
||||
CDEFINE= -DZ=65000
|
||||
CDEFINE= -DS=65000
|
||||
|
||||
# Include files that are needed to compile
|
||||
#
|
||||
|
||||
@@ -25,11 +25,11 @@ see the [original code](#original-code) section.
|
||||
This alternate version, which we recommend that you use in order to see what is
|
||||
happening with modern systems, and to not flash too quickly, which can be
|
||||
problematic for some people, can be configured to different speeds by way of the
|
||||
value used in `usleep()`. The default is `-DZ=65000` but you can easily change
|
||||
value used in `usleep()`. The default is `-DS=65000` but you can easily change
|
||||
it. To do so try:
|
||||
|
||||
```sh
|
||||
make CDEFINE="-DZ=70000" clobber alt
|
||||
make CDEFINE="-DS=70000" clobber alt
|
||||
./sloane.alt
|
||||
```
|
||||
|
||||
@@ -37,7 +37,7 @@ If you wish to make it like the original, as if the below [Original
|
||||
code](#original-code) was being used, you can do:
|
||||
|
||||
```sh
|
||||
make CDEFINE="-DZ=0" clobber alt
|
||||
make CDEFINE="-DS=0" clobber alt
|
||||
./sloane.alt
|
||||
```
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ KXw{Y" "RsFwsFwsFw{zaqyaz|FmMpyaoyI\\]cuUw{J"
|
||||
"~|_."[c(6,"b" "cd\\a[g","^`" "_e"
|
||||
"]fh")+8], p( "#$%" "&'()*+,-.1"[ c(11
|
||||
,"_ac[]\\YZi" "jkm", "`bd^efghXWlV" )+13
|
||||
]-34,a);}main (k ){ float z[1920] ,A=0
|
||||
]-34,a);}main (k,Z )char**Z;{float z[1920] ,A=0
|
||||
,B=0 ,i,j; puts("" "\x1b" "[2J");for(;;
|
||||
) { float e=sin(A ), n= sin(B),g=cos(
|
||||
A),m =cos(B);for(k =0;k< 1840;k++)y=-k
|
||||
@@ -27,6 +27,6 @@ A),m =cos(B);for(k =0;k< 1840;k++)y=-k
|
||||
g)*m-c* d*e-f*g-l*d*n);if(D>z[o] )z[o]
|
||||
=D,b[o] =" ..,,-++=#$@"[ N>0?N:0
|
||||
] ; } printf(
|
||||
"\x1b[" "H" );usleep(Z);for(k =1;1841
|
||||
"\x1b[" "H" );usleep(S);for(k=1;1841
|
||||
>k;k++) putchar (k%80?b [k]:10)
|
||||
; A += 0.053;B +=0.037 ; } }
|
||||
@@ -13,7 +13,7 @@ KXw{Y" "RsFwsFwsFw{zaqyaz|FmMpyaoyI\\]cuUw{J"
|
||||
"~|_."[c(6,"b" "cd\\a[g","^`" "_e"
|
||||
"]fh")+8], p( "#$%" "&'()*+,-.1"[ c(11
|
||||
,"_ac[]\\YZi" "jkm", "`bd^efghXWlV" )+13
|
||||
]-34,a);}main (k ){ float z[1920] ,A=0
|
||||
]-34,a);}main (k,Z )char**Z;{float z[1920] ,A=0
|
||||
,B=0 ,i,j; puts("" "\x1b" "[2J");for(;;
|
||||
) { float e=sin(A ), n= sin(B),g=cos(
|
||||
A),m =cos(B);for(k =0;k< 1840;k++)y=-k
|
||||
|
||||
+17
-9
@@ -1859,19 +1859,27 @@ Cody fixed this entry to work with clang which has a defect with the args to
|
||||
`main()`: it requires specific types: `int` and `char **` for the first and
|
||||
latter args.
|
||||
|
||||
Curiously, although clang requires the types of args to be strictly
|
||||
correct it allows for only one arg which Cody made it as the second arg was not
|
||||
used and this allows for a closer match to the original format of the entry.
|
||||
|
||||
He also made sure that the Makefile links in `libm` as not all systems do this by default.
|
||||
|
||||
Since the author suggested that the lack of certain `#include`s might break the
|
||||
program in some systems he added `-include ...` to the Makefile as well.
|
||||
|
||||
The [alternate version](2006/sloane/sloane.alt.c), which allows one to see what
|
||||
is going on in modern systems, and which we recommend one use _first_, was
|
||||
provided by Cody.
|
||||
|
||||
Curiously, although clang requires the types of args to be strictly correct,
|
||||
some versions do allow only one arg. This was done at first because it's not
|
||||
used but Cody discovered that later versions of clang have an additional defect
|
||||
where it does not allow only one arg so the second arg to `main()` was added
|
||||
back. This was an unfortunate problem for the alt code as he has been using Z
|
||||
for alt code `usleep()` (for sleep) but
|
||||
in this case unfortunately the original entry used `Z` in `main()` (though
|
||||
unused) so to make it more like the original Cody renamed the macro `Z` for
|
||||
`usleep()` to `S` instead which can stand for sleep and also it is kind of like
|
||||
a backwards `Z`. That way `Z` could be in `main()`.
|
||||
|
||||
Cody also made sure that the Makefile links in `libm` as not all systems do this
|
||||
by default.
|
||||
|
||||
Since the author suggested that the lack of certain `#include`s might break the
|
||||
program in some systems he added `-include ...` to the Makefile as well.
|
||||
|
||||
|
||||
## [2006/toledo2](2006/toledo2/toledo2.c) ([README.md](2006/toledo2/README.md]))
|
||||
|
||||
|
||||
Reference in new issue
Block a user