Im currently trying to seperate my files to make it easier for myself later on. Anyway Im having some trouble with passing structs into functions that dont have the struct defined in its header
Im compiling like this
gcc *.c -o blackjack2 -W -Wall -ansigame.c:10: warning: `struct player' declared inside parameter list
game.c:10: warning: its scope is only this definition or declaration, which is probably not what you want
game.c: In function `game':
game.c:10: warning: unused parameter `head'
game.c: At top level:
game.c:15: warning: `struct player' declared inside parameter list
game.c: In function `makeBet':
game.c:15: warning: unused parameter `head'
game.c: At top level:
game.c:20: warning: `struct player' declared inside parameter list
game.c: In function `dealHand':
game.c:20: warning: unused parameter `head'
game.c:20: warning: unused parameter `dealerhand'
game.c: In function `inHand':
game.c:25: warning: unused parameter `hand'
game.c: At top level:
game.c:30: warning: `struct player' declared inside parameter list
game.c: In function `memHandAllocate':
game.c:30: warning: unused parameter `head'
game.c:30: warning: unused parameter `dealerhand'
game.c: At top level:
game.c:35: warning: `struct player' declared inside parameter list
game.c: In function `memHandFree':
game.c:35: warning: unused parameter `head'
game.c:35: warning: unused parameter `dealerhand'
The last few errors about unused parameters in each function I am aware of and know why as the function isnt doing anything at the point in time.
My game.h looks like this
As you can see its just has function prototypes and nothing more. The file that contains the structure is player.h which also has a player.c file which makes it a Linked List eventually.Code:int game(struct player *head); int makeBet(struct player *head); int dealHand(struct player *head, char *dealerhand[10]); int inHand(char *hand[10]); void memHandAllocate(struct player *head, char *dealerhand[10]); void memHandFree(struct player *head, char *dealerhand[10]);
player.h
Now without using the game.h header file I get no errors so i know its the game.h / game.c errors.Code:#include <stdio.h> #include <stdlib.h> #include <string.h> #define NUMPLAYERS 3 /* Numplayers is computer players so 3 is, 3 computer opponents, dealer and user */ /* Player Structure */ struct player { char name[80]; char *hand[10]; int wins; int draw; int lost; float money; float currentbet; struct player *next; }; /* Player Prototypes */ int initPlayers(struct player **head); int addNode(struct player **head, char *name); char *namelist(void); void getUsersName(char *name, size_t size); void listShow(struct player **head); int freeList(struct player **head);
I then have a main file called blackjack2.c which calls the header files
This file doesnt really do much other than include the files required for the program to work and use the int main() function to start the program.Code:#include <time.h> #include "deck.h" #include "player.h" #include "game.h" /* more code below */
Now I am wondering how can I not get the errors I thought about just putting the functions from game.h/game.c into the player.h/player.c file (which works no problems) however my goal is to try and seperate my code as much as possible and this isnt working as well as Id hoped.
Ive also tried including the player.h header in game.h with no luck, just the same errors.
I am wondering is there a way to do this? Am I doing something wrong in the main file? Am I making any sense ?