N
Norm Bullen
Guest
It is my understanding that a typedef name is simply an alias for an existing type, whether the type is native or declared by the user. Why do I get a warning '=': incompatible types - from 'DIRECTORY_DATA *' to 'DirectoryData *' when I write an assignment from a variable declared as DirectoryData* to another variable declared as DIRECTORY_DATA*?
typedef struct DirectoryData {
DirectoryData* pNext;
DirectoryData* pPrev;
} DIRECTORY_DATA;
struct {
DIRECTORY_DATA* pFirst;
DIRECTORY_DATA* pLast;
} list;
DIRECTORY_DATA* pRecord;
pRecord->pNext = list.pFirst; // warning '=': incompatible types - from 'DIRECTORY_DATA *' to 'DirectoryData *'
If DIRECTORY_DATA is simply a synonym for "struct DirectoryData" why do I get the above warning?
I realize that I can get around the problem by changing the declaration of "list" or (probably) by using "alias" instead of "typedef".
Thanks
Norm
I just realized that my actual code has the keyword "struct" preceding pFirst and pLast in the declaration of list. Correcting the code to make it as above solves the problem.
Continue reading...
typedef struct DirectoryData {
DirectoryData* pNext;
DirectoryData* pPrev;
} DIRECTORY_DATA;
struct {
DIRECTORY_DATA* pFirst;
DIRECTORY_DATA* pLast;
} list;
DIRECTORY_DATA* pRecord;
pRecord->pNext = list.pFirst; // warning '=': incompatible types - from 'DIRECTORY_DATA *' to 'DirectoryData *'
If DIRECTORY_DATA is simply a synonym for "struct DirectoryData" why do I get the above warning?
I realize that I can get around the problem by changing the declaration of "list" or (probably) by using "alias" instead of "typedef".
Thanks
Norm
I just realized that my actual code has the keyword "struct" preceding pFirst and pLast in the declaration of list. Correcting the code to make it as above solves the problem.
Continue reading...