I'm using Visual Studio. I have come across code like the following:

typedef struct A_def A;
typedef struct A *A_ptr;

A_def is hidden. It's an opaque type. It's implementation is hidden so when I go to its definition, nothing happens in VS.

Is this because the implementation/definition is hidden in a .dll or .lib file? And if so, how can I confirm the presence of the definition of A_def by using dumpbin or similar tool?

Also, if this is truly an opaque type why would it be referred to as a future-declared structure or a forward declaration (such definitions of opaque types are being thrown around), because it's already declared and is only hidden from the user?

1

There are 1 best solutions below

4
On

This is just a forward declaration. The definition is needed during the compile time (unless you are using only the pointers to the struct) and is not hidden in a dll or lib.

"Go to defnition" is part of intellisense of visual studio, and it may not have found the definition of the struct in the source files that it parsed.

Structures are usually forward declared if there are cyclic dependencies or in order to separate the interface from the implementation.