build: fix windows build

Be very careful with forward declarations, MSVC is quite picky and
rather stupid about it.

Fixes #5810.