8

This seems like fairly basic functionality but, everywhere I look, the answer seems to be no.

Here's the thing: I've got a folder full of files I need to include in a c++ application. They're all named "FileX.h" where X is a number from 1 to 400. I did this because I figured there was a way I could say something like #include "File*.h" and it would include every file that fits that pattern. The order in which the files are included does not matter. I realize now I probably should have made the files into a shared library or something similar but, for future reference, I'd really like to know if this is possible.

So, is there someway to include all of these files with one #include statement? Or, failing that, is there a way to include a whole directory worth of files (ie. #include "C:/project/includes/") in c++?

YSC
  • 38,212
  • 9
  • 96
  • 149
Hoyt
  • 317
  • 3
  • 7

1 Answers1

8

AFAIC, the answer is no.

If you are doing this same list of files in multiple places, create another master header file that explicitly includes all the header files and then just include that one master header file in all your source files.

Depending on what you have going, there should be some way to automate the creating of this master header file.

Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
  • Nope, just have to do it the one time. I still put all the includes in their own file anyway (mainly because it was written via a script). – Hoyt Nov 10 '12 at 17:59