In general, I'm wondering if a program like this, containing a forward-declaration of a class that is never defined, is technically well-formed?
class X;
int main() {}
More specifically, I'm wondering if having a pattern like this
// lib.h
#pragma once
struct X {
private:
friend class F;
};
is safe to write if lib.h belongs to a shared library that does not contain a definition of the class F, nor does it depend on another shared library that does.
Is it possible that someone using the header file ends up with a reference to symbol F that may cause a linker error when loading the shared library?