Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include all files in a directory?

How can one achieve what the following code is trying to do?

#include "dir/*" 
like image 254
Karl Glaser Avatar asked Jun 17 '10 12:06

Karl Glaser


People also ask

HOW include file in parent directory in php?

If the referenced object is a folder, the function will return the parent folder of that folder. For the current folder of the current file, use $current = dirname(__FILE__); . For a parent folder of the current folder, simply use $parent = dirname(__DIR__); .

How do I get a list of files in a directory in C ++?

You can use opendir / readdir / closedir. Sample code which searches a directory for entry ``name'' is: len = strlen(name); dirp = opendir("."); while ((dp = readdir(dirp)) !=

How can I get a list of all the subfolders and files present in a directory using php?

PHP using scandir() to find folders in a directory The scandir function is an inbuilt function that returns an array of files and directories of a specific directory. It lists the files and directories present inside the path specified by the user.


2 Answers

In Bash:

HEADER=all_headers.h echo "#ifndef __ALL_HEADERS__" > $HEADER echo "#define __ALL_HEADERS__" >> $HEADER for file in dir/*.h do     echo "#include <$file>" >> $HEADER done echo "#endif" >> $HEADER 
like image 147
el.pescado - нет войне Avatar answered Sep 23 '22 17:09

el.pescado - нет войне


You can't, without running a script beforehand that generates all #include statements.

The preprocessor can only handle one file per #include statement, so it requires an actual #include for every single file you wish to be included in preprocessing.

like image 37
Jordan Lewis Avatar answered Sep 25 '22 17:09

Jordan Lewis