I'm writing an message application and want to split my application into multiple files. So far, everything related to bitwise operations is in one, another one contains various other handy functions.
Now I want to make a file with the phone and message related functions. In this file I would like to define the structs as well, but I'm facing the following error:
error: invalid application of 'sizeof' to incomplete type 'struct phone'This is only when the struct is moved outside the main file.. The file is include like this:
top of main file
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <time.h>
- #include "bitwise.h"
- #include "helpers.h"
- #include "phone.h"
- int main() {
- struct phone * phone = malloc(sizeof(struct phone));
- ...
- ...
- }
Expand|Select|Wrap|Line Numbers
- #include "phone.h"
- #include <stdlib.h>
- #include <stdio.h>
- struct message {
- char * part1, * part2, * part3;
- unsigned int msgID;
- char created[9];
- unsigned int phoneNum;
- unsigned int size;
- unsigned char flags;
- };
- struct phone {
- struct message msg[200];
- char text[600][64];
- unsigned char bitmap[75];
- int count;
- };
- struct message * newMessage(struct phone * phone, char * params[]) {
- return NULL;
- }
- #ifdef SOLO
- int main() { return 0; }
- #endif
Expand|Select|Wrap|Line Numbers
- #ifndef PHONE_H_
- #define PHONE_H_
- #endif /*PHONE_H_*/
K