C headerfiles and redefinition error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

C headerfiles and redefinition error

hi, I have problem with Visual C compiler cause I made some header files and I included them in my project main source, and I defined 3 arrays in one of those header files, unfortunately I get redefinition error on those lines which I defined the arrays. How can I solve this problem?

27th Nov 2018, 5:45 PM
Matin Zamani
Matin Zamani - avatar
3 Answers
+ 1
would you please share your code?
27th Nov 2018, 6:21 PM
jamilxt
jamilxt - avatar
0
this is the header file which the error is made in: #include<stdlib.h> #include"graphics.h" #define BOARD_WIDTH 5 #define PLAYER1 true #define PLAYER2 false int mapV[BOARD_WIDTH + 1][BOARD_WIDTH]; /* define this for vertical lines*/ int mapH[BOARD_WIDTH][BOARD_WIDTH + 1]; /*define this for horizontal lines*/ int scores[BOARD_WIDTH][BOARD_WIDTH]; /*define this for saving scores along the game*/ bool turn; /*this boolean value is set save the turn along the game*/ bool checkInputs(int z, int x, int y, int mapV[BOARD_WIDTH + 1][BOARD_WIDTH], int mapH[BOARD_WIDTH][BOARD_WIDTH + 1]); void initMapAndScores(int mapV[BOARD_WIDTH + 1][BOARD_WIDTH], int mapH[BOARD_WIDTH][BOARD_WIDTH + 1], int score[BOARD_WIDTH][BOARD_WIDTH]); void DecidePlayerTurn(bool turn); int GameRun(bool turn);
27th Nov 2018, 9:05 PM
Matin Zamani
Matin Zamani - avatar
0
in addition to this header file I have some others but not related to this header file,only they'll included in my mainsource.c but this gives me a redefinition error
27th Nov 2018, 9:07 PM
Matin Zamani
Matin Zamani - avatar