• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

comparison of complete and incomplete pointers

I'm compiling a short program, and I'm getting a warningin this section - the log is indicating my while statement.

Warning is: [Warning] comparison of complete and incomplete pointers

I guess I need some help understanding what it means by an incomplete pointer?

(p.s. I can certainly provide the rest of the program if anyone needs it.)
//function to print employee table using pointers
void premps2(struct employee *ptr, int n)
{
    struct phone * endptr = ptr + n;                  //pointer to end of struct    
    
    while(ptr < endptr)
    {
         printf("Name: %s\t\tPhone: (%s)%s-%s\n", ptr -> name, 
                ptr -> phone.area_code, ptr-> phone.prefix, 
                ptr-> phone.last_four);
         ptr++;
    }
}

Open in new window

0
Geisrud
Asked:
Geisrud
  • 2
1 Solution
 
Infinity08Commented:
I assume that this :

>>     struct phone * endptr = ptr + n;

should have been :

         struct employee * endptr = ptr + n;
0
 
GeisrudAuthor Commented:
You are correct.

It's always the stupid stuff.  Thanks!
0
 
Infinity08Commented:
No problem ;)
0
 
evilrixSenior Software Engineer (Avast)Commented:
>> I guess I need some help understanding what it means by an incomplete pointer?
At this point has the compiler seen the full definition of employee and phone or just the forward declarations? If not the compiler won't know the size of the objects the pointers refer to so they are deemed as incomplete pointer types.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now