views:

133

answers:

2

Is there a tool that would go through a list of files and would spit out a header file with forward declarations of classes it encounters? Ideally, I would like to integrate it into Visual C++'s build process.

+1  A: 

Not that I know of. But I guess that all that you want are class names, so grep, awk or something like that would do the job.

e8johan
I need class names + their template declarations. I don't know if that would be possible without using an actual parser?
Marcin Seredynski
Can I ask what you need it for? It seems like an odd thing to do...
e8johan
I want to generate a single header file with all the class declarations, so I can include it and have less forward-declaration-clutter in my headers. Why does it seem odd? Is it a bad practice?
Marcin Seredynski
It seems odd that your project would require more than just a couple forward declarations.
John Dibling
This would force a rebuild of the entire project every time you add a class. It's better for each header to forward declare just the classes it needs - if your classes are a reasonable size, then they shouldn't need more than a handful of declarations.
Mike Seymour
@John Dibling: It's not like my project **needs** those declarations per se. It's just about me being used to C# "no-header, no-declaration bliss" over the years and wanting to see if it would be a good approach for C++. From the feedback I got it seems it woudln't.
Marcin Seredynski
A: 

You can grep and save replacements to a file.

John Dibling