I have a header and a sample application using this header, all in C, I get almost all the logic of this software except for this; this the interesting part of the header:
struct A;
typedef struct A A;
in the C application this A is only used when declaring a pointer like this
A* aName;
I’m quite sure that this is a solution for just including A in the scope/namespace and give just a name to a basically void pointer, because this kind of pointer is only used to handle some kind of data, it is more like some namespace sugar.
What this could be for?
You’re correct that it’s like a void pointer, in that
voidis an incomplete type, and in this fileAis also an incomplete type. About all you can do with incomplete types is pass around pointers to them.It has one advantage over
void*in this file, that it’s a different and incompatible type from some other bit of code that has done the same thing withB. So you get a bit of type safety. IfAiswindowHandleandBisjpgHandle, then you can’t pass the wrong one to a function.It has an advantage over
void*in the.cfile that defines the functions that accept anA*— that file can contain a definition ofstruct A, and giveAwhatever members it wants, that the first file doesn’t need to know about.However, you say there are no other mentions of
Ain any header file, which means there are no functions that accept or return it. You also say that the only use ofAin your source file is to declare pointers — I wonder where the values of those pointers come from, if any.If all that happens if that someone defines an uninitialized
A*and never uses it, then clearly this is a remnant of some old code, or the start of some code that never got written, and it shouldn’t be in the file at all.Finally, if the real type is called something a bit less stupid than
A, then the name might give a clue to its use.