I can't get this code to work. It worked fine when it was all in one file, but when I split it up and put in the header file, I got all of these errors like (VERTEX has no member p) and (VERTEX has no member isVisited); strangely, no errors for C. What am I missing? What am I doing wrong?
#ifndef MY_HEADER_INCLUDED
#define MY_HEADER_INCLUDED
struct EDGETAG;
struct LINKTAG;
//struct VERTTAG;
typedef struct
{
char c;
bool isVisited;
EDGE* p;
} VERTEX;
typedef struct EDGETAG
{
VERTEX* v;
struct EDGETAG* q;
} EDGE;
typedef struct LINKTAG
{
VERTEX* v;
struct LINKTAG* next;
} VERTLINK;
int main(int argc, char *argv[]);
void bredthfirst(VERTLINK * start, int numVerts);
void depthfirst(VERTLINK * start, int numVerts);
void depthfirst(VERTLINK * start, int numVerts);
void showchart(VERTLINK * start, int numVerts);
#endif
and here is a short sample from the file that contains main, near the bottom is where the errors where popping up
#include "myheader.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
int main(int argc, char *argv[])//(void)//
{
FILE* fileAddress;
int numVerts = 0;//0;
int temper = 10;
int * intArray;
char templine[200];// = " ";//5];// = " b";
int getIndex = 0;
int c = 0;
int f = 0;
int exitLoop = 0;
bool vertfound = false;
fileAddress = fopen(argv[1],"r");//
int counter = 0;
VERTLINK * currentlink;
VERTLINK firstlink;
VERTEX * tempvert;
VERTEX * tempvertoo;
EDGE * tempedge;
EDGE * tempedgetoo;
VERTLINK * templink;
VERTLINK * templinktoo;
while(fgets(templine, sizeof(templine), fileAddress) != NULL)
{
counter = 0;
currentlink = &firstlink;
while(templine[counter] == ' ')
{
counter++;
}
for(f = 0; f < numVerts; f++)
{
if( (*(*currentlink).v).c == templine[counter])
{
vertfound = true;
f = numVerts + 1;
}
else
{
if(f < numVerts - 1)// && numVerts != 6)
{
currentlink = (*currentlink).next;
tempvert = (*currentlink).v;
}
}
}
if(vertfound)
{vertfound = false;
}
else
{
if(numVerts == 0)
{
tempvert = malloc(sizeof (VERTEX));
firstlink.v = tempvert;
firstlink.next = NULL;
(*firstlink.v).c = templine[counter];
(*firstlink.v).isVisited = false;
(*tempvert).p = NULL;
numVerts++;
}
Here is what the compiler said:
C:\...\CProject\finaldata\myheader.h|13|error: expected specifier-qualifier-list before 'bool'|
C:\...\CProject\finaldata\cgraph.c||In function 'main':|
C:\...\CProject\finaldata\cgraph.c|105|error: 'VERTEX' has no member named 'isVisited'|
C:\...\CProject\finaldata\cgraph.c|106|error: 'VERTEX' has no member named 'p'|
C:\...\CProject\finaldata\cgraph.c|126|error: 'VERTEX' has no member named 'p'|
C:\...\CProject\finaldata\cgraph.c|131|error: 'VERTEX' has no member named 'isVisited'|
C:\...\CProject\finaldata\cgraph.c|149|warning: comparison between pointer and integer|
C:\...\CProject\finaldata\cgraph.c|160|error: 'VERTEX' has no member named 'p'|
C:\...\CProject\finaldata\cgraph.c|164|error: 'VERTEX' has no member named 'p'|
C:\...\CProject\finaldata\cgraph.c|196|error: 'VERTEX' has no member named 'isVisited'|
C:\...\CProject\finaldata\cgraph.c|197|error: 'VERTEX' has no member named 'p'|
C:\...\CProject\finaldata\cgraph.c|221|error: 'VERTEX' has no member named 'p'|
C:\...\CProject\finaldata\cgraph.c|231|error: 'VERTEX' has no member named 'p'|
C:\...\CProject\finaldata\cgraph.c|271|error: 'VERTEX' has no member named 'isVisited'|
C:\...\CProject\finaldata\cgraph.c|273|error: 'VERTEX' has no member named 'p'|
C:\...\CProject\finaldata\cgraph.c|348|warning: implicit declaration of function 'topo'|
C:\...\CProject\finaldata\cgraph.c|361|error: 'VERTEX' has no member named 'p'|
C:\...\CProject\finaldata\cgraph.c|362|error: 'VERTEX' has no member named 'p'|
C:\...\CProject\finaldata\cgraph.c|388|error: 'VERTEX' has no member named 'p'|
C:\...\CProject\finaldata\cgraph.c|390|error: 'VERTEX' has no member named 'p'|
C:\...\CProject\finaldata\cgraph.c|391|error: 'VERTEX' has no member named 'p'|
C:\...\CProject\finaldata\cgraph.c|414|error: 'VERTEX' has no member named 'p'|
C:\...\CProject\finaldata\cgraph.c|415|error: 'VERTEX' has no member named 'p'|
||=== Build finished: 20 errors, 2 warnings ===|