aboujouj83
IS-IT--Management
I am having a parsing error when I am compiling a big C program that implements a unix shell.
I am using gcc compiler in sun os 5.8.
the problem is related to this part of the code:
-----------------------------------------------------------
void shinit(myshenvTP P, char *pwd, char *path, char *home) {
if(MALLOC(P->PWD, MAX_LEN, char) || MALLOC(P->PATH, strlen(path)+1, char) || MALLOC(P->HOME,strlen(home)+1, char)){
fprintf(stderr, "No enough memory available!\n"
exit(EXIT_FAILURE);
}
strcpy(P -> PWD, pwd);
strcpy(P -> PATH, path);
strcpy(P ->HOME, home);
}
-----------------------------------------------------------
Note that I've already defined the type myshenvTP as:
-----------------------------------------------------------
typedef struct {
char *PWD;
char *PATH;
char *HOME;
}myshnvT, *myshenvTP;
-----------------------------------------------------------
The error that I am having is:
***********************************************************
> gcc -o gsh gshell.c
gshell.c: In function `shinit':
gshell.c:286: parse error before `||'
gshell.c: At top level:
gshell.c:294: parse error before `->'
gshell.c:294: warning: data definition has no type or storage class
gshell.c:296: parse error before `->'
gshell.c:296: warning: data definition has no type or storage class
gshell.c:298: parse error before `->'
gshell.c:298: warning: data definition has no type or storage class
***********************************************************
WAITING FOR ANY EXPLANATION!
THANKS,
ABOUJOUJ
I am using gcc compiler in sun os 5.8.
the problem is related to this part of the code:
-----------------------------------------------------------
void shinit(myshenvTP P, char *pwd, char *path, char *home) {
if(MALLOC(P->PWD, MAX_LEN, char) || MALLOC(P->PATH, strlen(path)+1, char) || MALLOC(P->HOME,strlen(home)+1, char)){
fprintf(stderr, "No enough memory available!\n"
exit(EXIT_FAILURE);
}
strcpy(P -> PWD, pwd);
strcpy(P -> PATH, path);
strcpy(P ->HOME, home);
}
-----------------------------------------------------------
Note that I've already defined the type myshenvTP as:
-----------------------------------------------------------
typedef struct {
char *PWD;
char *PATH;
char *HOME;
}myshnvT, *myshenvTP;
-----------------------------------------------------------
The error that I am having is:
***********************************************************
> gcc -o gsh gshell.c
gshell.c: In function `shinit':
gshell.c:286: parse error before `||'
gshell.c: At top level:
gshell.c:294: parse error before `->'
gshell.c:294: warning: data definition has no type or storage class
gshell.c:296: parse error before `->'
gshell.c:296: warning: data definition has no type or storage class
gshell.c:298: parse error before `->'
gshell.c:298: warning: data definition has no type or storage class
***********************************************************
WAITING FOR ANY EXPLANATION!
THANKS,
ABOUJOUJ