The following code compiles fine.
header.h:
typedef struct Placeholder_Type* Placeholder;
impl.cpp:
#include "header.h"
void doSomething(Placeholder t) {
(void) t;
}
int main() {
int *a = new int();
doSomething((Placeholder)a);
}
compilation command:
clang++ impl.cpp
The type Placeholder_Type does not exist anywhere and it doesn't exist as a symbol in the output binary.
Why is it legal to create a typedef for a type that does not exist?
Why can I create a function using a type that doesn't exist?
Is this equivalent to just using void* but named "Placeholder"?