Reputation: 1613
I have put each function in own file.
How do I include all those functions at once without repeating #include
for each file manually? I don't care at which order the functions are included.
All the functions from hundreds of different files belongs to the same group. Actually each file has 4 functions.
Upvotes: 1
Views: 5404
Reputation: 14692
is it C
or C++
question??
In C++, you usually have file per class, not function. And if, after having an .h and .cpp file per class, you still have hundreds of them in one directory, you need to reconsider your design. You probably need more abstraction layers, and you can divide your files in several directories.
Upvotes: 0
Reputation: 2957
Use a prebuild step and execute a batch file like the following:
@echo off
setlocal
set file=test.h
echo // generated > %file%
for %%f in (*.h) do echo #include "%%f" >> %file%
Then include test.h.
In VS2008 you can add a prebuild step in "Project" - "Properties" - "Configuration Properties" - "Build Events" - "PreBuild Event".
Set "Command Line" to $(ProjectDir)\test.cmd and copy test.cmd (with the above contens) to the project directory.
Upvotes: 3
Reputation: 27023
Consider your files.
file1.h
int plus(int a, int b);
file2.h
int minus(int a, int b);
file3.h
int mult(int a, int b);
file4.h
void drawcircle(int r, int xc, int yc);
file5.h
void drawsquare(int x0, int y0, int x1, int y1);
file6.h
void printresults();
Now divide your files into groups. Make the following files.
math_funcs.h
#include "file1.h"
#include "file2.h"
#include "file3.h"
draw_funcs.h
#include "file4.h"
#include "file5.h"
output_funcs.h
#include "file6.h"
Then make all.h
file.
all.h
#include "math_funcs.h"
#include "draw_funcs.h"
#include "output_funcs.h"
Upvotes: 8
Reputation: 15778
Upvotes: 2