user1985536
user1985536

Reputation:

How include a directory of headers in C

I would like to know how can I include a directory containig several headers in a C program instead of including all the headers one by one.

Upvotes: 2

Views: 127

Answers (3)

ouah
ouah

Reputation: 145829

You can write an header that individually includes the other headers and then include this header elsewhere. But an include directive can only include one single header.

Upvotes: 2

Nikolai Fetissov
Nikolai Fetissov

Reputation: 84151

There's no such facility in C. Create a master header file that includes everything that's in that directory, and have your clients include that.

A side-note: it's always better to know what exactly you are #include-ing, i.e. hand-pick needed header files, instead of doing this thing wholesale to avoid name clashes, unexpected macro expansion, circular dependencies, and what not.

Upvotes: 2

StilesCrisis
StilesCrisis

Reputation: 16290

This is not directly possible in C. You must include headers individually or make some sort of preprocessing step in your makefile which synthesizes a header which #includes the others.

Upvotes: 2

Related Questions