Ahoj hoši, viete mi pomôcť, ako skompilovať tento projekt? Projekt ma viacero súborov no ide mi o k.c a k.h a k.o Pri zadaní make k mi vyskočia chybové hlášky
- k.c:15:6: error: conflicting types for ‘render’
In file included from k.c:3:0:
k.h:19:6: note: previous declaration of ‘render’ was here
k.c:23:6: error: conflicting types for ‘is_move_possible’
In file included from k.c:3:0:
k.h:40:6: note: previous declaration of ‘is_move_possible’ was here
k.c:26:6: error: conflicting types for ‘is_game_won’
In file included from k.c:3:0:
k.h:48:6: note: previous declaration of ‘is_game_won’ was here
k.c: In function ‘is_game_won’:
k.c:28:1: error: control reaches end of non-void function [-Werror=return-type]
k.c: In function ‘is_move_possible’:
k.c:25:1: error: control reaches end of non-void function [-Werror=return-type]
k.c: In function ‘update’:
k.c:22:1: error: control reaches end of non-void function [-Werror=return-type]
cc1: all warnings being treated as errors
Problém je v súbore k.c ibaže neviem ako to skompilovať. Neviem čo má byť v zátvorkách, môžete mi to prosím zmeniť? Zvýrazním to tučným písmom to, čo treba zmeniť.
K.c
#include <stdio.h>
#include <stdlib.h>
#include "k.h"
void add_random_tile(struct game *game){
int row, col;
// find random, but empty tile
do{
row = rand() % 4;
col = rand() % 4;
}while(game->board[row][col] != ' ');
// place to the random position 'A' or 'B' tile
int tile = 'A' + (rand() % 2);
game->board[row][col] = tile;
}
void render(struct game *game)
{
}
bool update(struct game *game, int dy, int dx)
{
}
bool is_move_possible(struct game *game){
}
bool is_game_won(struct game *game){
}
K.h
#include <stdbool.h>
struct game {
char board[4][4];
int score;
};
void add_random_tile(struct game *game);
void render(const struct game game);
bool update(struct game *game, int dy, int dx);
bool is_move_possible(const struct game game);
bool is_game_won(const struct game game);
Funkcia main bude obsiahnutá v súbore main.c
Makefile
#variables
CC = gcc
CFLAGS = -std=c11 -Wall -Werror
LDLIBS = -lm
OUTPUT = game
#targets
all: $(OUTPUT)
$(OUTPUT): hof.o k.o main.o
$(CC) $(CFLAGS) hof.o k.o main.o $(LDLIBS) -o $(OUTPUT)
main.o: main.c
$(CC) $(CFLAGS) main.c -c $(LDLIBS) -o main.o
k.o: k.c
$(CC) $(CFLAGS) k.c -c $(LDLIBS) -o k.o
hof.o: hof.c
$(CC) $(CFLAGS) hof.c -c $(LDLIBS) -o hof.o
clean:
rm -rf $(OUTPUT)
rm -rf hof.o
rm -rf k.o
rm -rf main.o