newbie for C

  • Thread starter Thread starter Sandy
  • Start date Start date
S

Sandy

Having problem on using the -> operator in C.
aFile.C
struct _process* initProcess(void){
struct _process* tmpProcess;
tmpProcess = palloc();
tmpProcess->PID = 0;
tmpProcess->next = 0;
return tmpProcess;
}
bFile.C
initProcess()->PID =2;

I always get this error "error C2037: left of 'PID' specifies undefined
struct/union '_process'", where process is a well defined struct with memory
allocated and the member PID was assigned a value.
The initProcess was able to allocate the memory for the structure and
initialize the member values.
Where is my mistake?
Thanx
 
Check that bfile includes the header that defines the struct. If it does
then try this...

I am not sure that you can do this (but may be wrong)
initProcess()->PID =2;
in "C". I think that would only work with a C++ compiler. Change it to this
instead and see if it works

struct _process *varname = initProcess();
varname->PID=2;
 
Back
Top