Updated to be fully C99 compatible

This commit is contained in:
AnnaSnoeijs 2025-08-15 19:35:55 +02:00
parent b0240c4911
commit 9a8665ed26
2 changed files with 10 additions and 4 deletions

View file

@ -143,8 +143,14 @@ int main(
playboard.rows = (rowsint_t)atoi(optarg); playboard.rows = (rowsint_t)atoi(optarg);
break; break;
case 'o': case 'o':
filename = strdup(optarg); // filename = strdup(optarg);
outputfile = fopen( filename, "w" ); filename = calloc( strlen( optarg ) + 1, sizeof(char) );
if( filename != NULL ){
strcpy( filename, optarg );
outputfile = fopen( filename, "w" );
}else{
fprintf( stderr, "ERR: COULD NOT ALLOCATE FILENAME\n" );
}
break; break;
} }
} }
@ -185,7 +191,7 @@ int main(
playboard.height = calloc( playboard.columns, sizeof(rowsint_t) ); playboard.height = calloc( playboard.columns, sizeof(rowsint_t) );
playboard.column = calloc( playboard.columns, sizeof(column_t) ); playboard.column = calloc( playboard.columns, sizeof(column_t) );
if( playboard.height == NULL || playboard.column == NULL ){ if( playboard.height == NULL || playboard.column == NULL ){
fprintf( stderr, "ERROR: COULD NOT ALLOCATE BOARD" ); fprintf( stderr, "ERROR: COULD NOT ALLOCATE BOARD\n" );
return 1; return 1;
} }
// Initialize wins struct if used // Initialize wins struct if used

View file

@ -7,7 +7,7 @@ ARCH = native
O = s O = s
# Flags for the compiler # Flags for the compiler
FLAGS = -std=gnu99 FLAGS = -std=c99
FLAGS += -O$(O) FLAGS += -O$(O)
FLAGS += -march=$(ARCH) FLAGS += -march=$(ARCH)
# Only override gcc default tuning if specified in make command line # Only override gcc default tuning if specified in make command line