in my project i have three files: PlayBoard.c, Board. c, Board.h, who's relevant parts appear bellow. within PlayBoard i have theBoard which is a pointer to a variable of type struct Board. when trying to compile i constantly get a "dereferencing pointer to incomplete type". moving Board's definition to Board.h helps, but is not possible (it's a homework question), so i need another way.
PlayBoard.c:
#include "Board.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
...
int main()
{
BoardP theBoard =//creation of new Board;
...
}
Board.h:
#ifndef BOARD_H
#define BOARD_H
// ------------------------------ includes ------------------------------
#include <stdbool.h>
#include <stdio.h>
// -------------------------- definitions -------------------------
/**
* A pointer to Gomoku table.
*
*/
typedef struct Board* BoardP;
/**
* A struct of a Gomoku table.
*/
typedef const struct Board* ConstBoardP;
...
#endif
and Board.c:
#ifndef BOARD_C
#define BOARD_C
#include "Board.h"
typedef struct Board
{
char **_board;
int _cols;
int _rows;
bool _turn;
int _xCounter;
int _oCounter;
int _lastx;
int _lasty;
} Board;
...
#endif