mirror of
https://github.com/abakh/nbsdgames.git
synced 2025-02-02 15:07:27 -05:00
Now gets compiled under tcc w/ -D NO_VLA
This commit is contained in:
parent
9abf0a429a
commit
7bd951a07a
10
sudoku.c
10
sudoku.c
@ -27,9 +27,10 @@ unsigned int filled;
|
|||||||
chtype colors[6]={0};
|
chtype colors[6]={0};
|
||||||
|
|
||||||
|
|
||||||
#if defined Plan9 //the Plan9 compiler can not handle VLAs
|
#ifdef NO_VLA//the Plan9 compiler can not handle VLAs
|
||||||
#define size 3
|
#define size 3
|
||||||
#define s 9
|
#define s 9
|
||||||
|
#ifdef Plan9
|
||||||
// I hope this is approximately right
|
// I hope this is approximately right
|
||||||
int round(float x)
|
int round(float x)
|
||||||
{
|
{
|
||||||
@ -40,6 +41,7 @@ int round(float x)
|
|||||||
y = (int)(x - 0.5); // the same but opposite
|
y = (int)(x - 0.5); // the same but opposite
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
byte size,s;//s=size*size
|
byte size,s;//s=size*size
|
||||||
#endif
|
#endif
|
||||||
@ -87,7 +89,7 @@ char int2sgn(byte num){// convert integer to representing sign
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isvalid(byte ty,byte tx,char board[s][s]){ //is it allowed to place that char there?
|
const bool isvalid(const byte ty,const byte tx,const char board[s][s]){ //is it allowed to place that char there?
|
||||||
char t= board[ty][tx];
|
char t= board[ty][tx];
|
||||||
if(!t)
|
if(!t)
|
||||||
return 0;
|
return 0;
|
||||||
@ -322,7 +324,7 @@ void gameplay(void){
|
|||||||
}
|
}
|
||||||
int main(int argc,char** argv){
|
int main(int argc,char** argv){
|
||||||
signal(SIGINT,sigint_handler);
|
signal(SIGINT,sigint_handler);
|
||||||
#ifndef Plan9
|
#ifndef NO_VLA
|
||||||
if(argc>4 || (argc==2 && !strcmp("help",argv[1])) ){
|
if(argc>4 || (argc==2 && !strcmp("help",argv[1])) ){
|
||||||
printf("Usage: %s [size [ difficulty]] \n",argv[0]);
|
printf("Usage: %s [size [ difficulty]] \n",argv[0]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@ -385,7 +387,7 @@ int main(int argc,char** argv){
|
|||||||
colors[b]=COLOR_PAIR(b+1);
|
colors[b]=COLOR_PAIR(b+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef Plan9
|
#ifndef NO_VLA
|
||||||
s= size*size;
|
s= size*size;
|
||||||
#endif
|
#endif
|
||||||
char board[s][s];
|
char board[s][s];
|
||||||
|
Loading…
Reference in New Issue
Block a user