5 Replies - 1050 Views - Last Post: 20 December 2007 - 09:35 AM Rate Topic: -----

#1 lockdown   User is offline

  • D.I.C Regular
  • member icon

Reputation: 6
  • View blog
  • Posts: 394
  • Joined: 29-September 07

#include <> question directives

Posted 18 December 2007 - 09:03 AM

I was just thinking about this today when I had to enter in a lot of directives when working on a couple programs.

Would it possible to combine them all into one directive. So you would uses #include <alldirectives> and that would included all the directives?

Kinda weird to explain but would something like that be possible?
Is This A Good Question/Topic? 0
  • +

Replies To: #include <> question directives

#2 MorphiusFaydal   User is offline

  • D.I.C Lover
  • member icon

Reputation: 44
  • View blog
  • Posts: 1,376
  • Joined: 12-May 05

Re: #include <> question directives

Posted 18 December 2007 - 09:20 AM

If you were to write your own compiler to do it, sure.
Was This Post Helpful? 0
  • +
  • -

#3 lockdown   User is offline

  • D.I.C Regular
  • member icon

Reputation: 6
  • View blog
  • Posts: 394
  • Joined: 29-September 07

Re: #include <> question directives

Posted 18 December 2007 - 09:23 AM

Um I think im going to pass on that then :).
Was This Post Helpful? 0
  • +
  • -

#4 Bench   User is offline

  • D.I.C Lover
  • member icon

Reputation: 945
  • View blog
  • Posts: 2,464
  • Joined: 20-August 07

Re: #include <> question directives

Posted 18 December 2007 - 11:54 AM

Maybe write your own header file? I don't recommend doing this (its poor practice), especially not if you like adding using declarations in your programs - you'll end up polluting the global namespace pretty heavily, but its the closest that standard C++ has to an #include <all> for the moment. Though I believe a standard <all> header is, or was at one point, being seriously considered for C++0x by the C++ standards committee.

#ifndef ALL_H
#define ALL_H

#include <istream>
#include <ostream>
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <limits>
#include <memory>
#include <sstream>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cassert>

/* TODO: Insert headers as needed */

#endif 

This post has been edited by Bench: 18 December 2007 - 12:02 PM

Was This Post Helpful? 0
  • +
  • -

#5 lockdown   User is offline

  • D.I.C Regular
  • member icon

Reputation: 6
  • View blog
  • Posts: 394
  • Joined: 29-September 07

Re: #include <> question directives

Posted 18 December 2007 - 01:38 PM

It would mainly be for the ones I am currently using (iostream, fstream, string)
Was This Post Helpful? 0
  • +
  • -

#6 NickDMax   User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2255
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: #include <> question directives

Posted 20 December 2007 - 09:35 AM

As bench pointed out, of you create a header file that includes all the other headers you need then you can just include that header in your source, and the compiler will cascade to all the rest. Some people swear by doing it this way -- keeping all the header information together. I personally like to keep the include near where I use its contents, that way I use my IDE to quickly open up the header file.

You know when I was new to C/C++ I thought reading the standard header files would make me a great programmer, then I came to the realization that they were just too complex. Later I started going back into them and they were no longer so complex -- now I often wade though them.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1