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?
Create a header file that includes them all and include that instead.
Ie, 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.