0

I know this question was asked in 2009:

Forward declaration of a typedef in C++

But given that was asked in 2009 is there seriously still no way to forward-declare a typedef/using statement?

user997112
  • 29,025
  • 43
  • 182
  • 361
  • 1
    Does the top answer (https://stackoverflow.com/a/804956/5754656) not answer your question? – Artyer Feb 13 '20 at 17:10
  • 2
    *But given that was asked in 2009 is there seriously still no way to forward-declare a typedef/using statement?* Yep. – NathanOliver Feb 13 '20 at 17:10
  • 2
    You cant create an alias of something if that something doesn't exist. – NathanOliver Feb 13 '20 at 17:11
  • 1
    No. You have to forward-declare the underlying type of the typedef, then you can declare the typedef. There's no demand for doing anything about it, so nothing changed. – Andrey Semashev Feb 13 '20 at 17:11
  • It would be very difficult to add such a feature to the language because, if typedefs could be forward declared, the compiler would not be able to determine identity between the forward-declared typedef and some other type. With forward-declared classes, this is not an issue because identity of classes goes by identity of names. – Brian Bi Feb 13 '20 at 17:18
  • The bad thing about is that you cannot pre-declare `typedef struct { /*...*/ } S;` at all – even today... – Aconcagua Feb 13 '20 at 17:20
  • In the end it was easier I just move all my typedefs to a single header and include that because that answer in the previous question was effectively redefining the typedef, totally pointless. – user997112 Feb 13 '20 at 17:26

0 Answers0