troubleshooting Question

Is it possible to forward declare a typedef'ed anonymous struct?

Avatar of evilrix
evilrixFlag for United Kingdom of Great Britain and Northern Ireland asked on
CC++
25 Comments2 Solutions7183 ViewsLast Modified:
I am integrating a number of 3rd partly library databases (for benchmarking) and I would like to keep the specific implementation details of this out of the header files. To this end I am forward declaring everything; however, I've just discovered one of the libraries defines an anonymous struct and typedefs it, something like this...

typedef struct {} MyStruct;

I can't forward declare this because the compiler quite rightly complains it finds a typedef that was previous declared as a struct.

My question then is, is it actually possible to forward declare this typedef? I've never encountered a reason to try and do this before so I hate to admit it but I am stumped :)

Just a simple yes, here's how or no is all I am after and not a lengthy discussion on the pros and cons of forward declaration vs. including the headers in my header -- I promise I know all the arguments ;)

Thanks.
ASKER CERTIFIED SOLUTION
evilrix
Senior Software Engineer (Avast)

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 25 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 25 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros