In my C++ code, I want to include many he开发者_开发百科ader files that are placed in one folder. how can i include them all at once?
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.
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.
You may wrap them in a helping header file. Having created it once, you can include
it everywhere.
精彩评论