PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: [Cs223] Compiler Error
Date: Thursday, 19 Mar 2020, 11:38:02


    > Message Posted By: Unknown
    >
    > I am getting the following error when I try to make my Deque.c:
    >
    > Deque.c: In function `addD':
    > Deque.c:125:16: error: `*d' is a pointer; did you mean to use `->'?
    >   125 |     stackPush(d->tailStack, *s);
    >                   |                ^~
    >
    > It seems that gcc is trying to suggest using '->' when it's already in
    > use?

I will assume that d is an argument to one of the Deque
functions so that d is a Deque*; i.e., d is a pointer to
a Deque variable.  [Had you sent mail to me rather than
posting to the newsgroup, I could look at your code to
verify this.]

d->FIELD is equivalent to (*d).FIELD.  Since d is a
Deque*, *d is a Deque (i.e., a pointer to a struct
deque), not a struct deque, and thus does not have any
fields, which generates the error message.

But (*d)->FIELD is equivalent to (**d).FIELD.  Since
**d is a struct deque, there would be no error message.

--Stan-
PREV INDEX NEXT