Aspirant Developer
Aspirant Developer

Reputation: 31

header files in C++

In my C++ code, I want to include many header files that are placed in one folder. how can i include them all at once?

Upvotes: 3

Views: 369

Answers (3)

edgar.holleis
edgar.holleis

Reputation: 4991

Execute the following shell commands in the directory which holds your .h files:

rm -f meta.h
echo "#ifndef META_H" >> meta.h
echo "#define META_H" >> meta.h
for h in `ls *.h`; do echo "#include \"$h\"" >> meta.h; done
echo "#endif /*META_H*/" >> meta.h

...and then #include "meta.h" alone.

Upvotes: 4

Dmitrii Volosnykh
Dmitrii Volosnykh

Reputation: 1185

You may wrap them in a helping header file. Having created it once, you can include it everywhere.

Upvotes: 1

ildjarn
ildjarn

Reputation: 62975

Create a header file that includes them all and include that instead.

I.e., I know of no compiler that has this functionality built in, and if one did it would certainly be non-standard functionality.

Upvotes: 11

Related Questions