简体   繁体   中英

C: struct X has no member named Y

I am working on a project with the XINU OS and while adding pipes to the system I get a compiler error when trying to add and use a new member to a struct I made earlier. I honestly can not see what is wrong with my code, especially when I compare it to working pieces that vary by a variable name.

"/pipcreate.c:21: error: 'struct pipent' has no member named 'owner'"

As for the two lines commented out (reader = PR_CURR, writer = PR_CURR) if I uncomment those, and comment out the 'owner' line, it does compile fine.

Does anything stand out as the obvious problem, and I am just completely overlooking it?

pipe.h

/*typedef int32 pipid32 inside of kernel.h*/

/* Max number of pipes in the system */
#ifndef NPIP
#define NPIP    10
#endif

/* Pipe state constants */

#define PIPE_FREE   0   /* pipe table entry is unused   */
#define PIPE_USED   1   /* pipe is currently used   */
#define PIPE_CONNECTED  2   /* pipe is currently connected  */

/* Misc pipe definitions */

#define isbadpipid(x)   ( ((pid32)(x) < 0) || \
          ((pid32)(x) >= NPIP) || \
          (piptab[(x)].pipstate == PIPE_FREE))

/* Definition of pipe table */

struct pipent {         /* entry in the pipe table  */
uint32 pipstate;    /* pipe state: PIP_FREE, ect.   */
uint32 pipid;       /* pipe ID in table         */
char buffer[256];   /* buffer to write to       */
pid32 writer;       /* pid for writer       */
pid32 reader;       /* pid for reader       */
pid32 owner;        /* CURR_PID upon pipe being created */
};

extern struct pipent piptab[];
extern int32 pipcount;

pipcreate.c

#include <xinu.h>
#include <string.h>

static pipid32 newpipid(void);
/*------------------------------------------------------------------------
 *  pipcreate - 
 *------------------------------------------------------------------------
 */
syscall pipcreate(void){
    intmask mask;     /* saved interrupt mask   */

//struct pipent piptab[];
struct pipent *piptr;       /* ptr to pipe's table entry */
pipid32 pipid;              /* ID of newly created pipe */

mask = disable();

pipid = newpipid();         /* pipid to return */
piptr->pipstate = PIPE_USED;
piptr->owner = PR_CURR;
    //piptr->writer = PR_CURR;
    //piptr->reader = PR_CURR;

pipcount++;                 /* increment number of pipes */
piptr = &piptab[pipid];

restore(mask);
return pipid;
}

//newpipid - obtain a new (free) pipe ID
local pipid32 newpipid(void)
{
uint32 i;   
static pipid32 nextpipid = 1;
/* Check all NPIP slots */
for(i = 0; i < NPIP; i++){
    nextpipid %= NPIP;  /* wrap around to beginning */
    if(piptab[nextpipid].pipstate == PIPE_FREE){
        return nextpipid++;
    } else {
        nextpipid++;
    }
}
return (pid32) SYSERR;
}

One possibility is that the source file pipcreat.c is not actually including pipe.h (from the shown #include list, it appears not). A simple check for this would be to add a blatant syntax error to pipe.h and see if the compiler complains about it.

If you're using gcc, add the -M option to the compiler command line - it'll spit out the full path of all the header files being included. grep that output for pipe.h and you'll find out why yours isn't being used.

It is a problem of the version of jvmti.h used by the jdk. A new method that exist in recent version of jvmti.h but dont exist before.

So I think the problem was something to do with having some object files still present after making changes and compiling again.

Basically I think I just had to run clean from my Makefile first, which I thought I had done, but maybe not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM