1
votes

Is there any way how include all neaded things just by one .h file ? (When I made try I get really lot of errors ...)

There is a small example of my meaning:

  • Includes:
    • main.cpp -> main.h (class & vars) -> includes.h
    • test.cpp -> test.h (class & vars) -> includes.h
    • includes.h
      • iostream
      • windows.h
      • somelib.h
      • ...
2
Huh? Do not understand.OldProgrammer
Visual studio has something like "precompiled headers", that all necessary includes are included in stdafx.h. These headers are parsed and compiled just once.V-X
These two was just examples I mean it for everything like some directx library or whatever else ...PSSGCSim
Reminder: if everything is in one include, anytime you make a change to the include file, everything is rebuilt. To speed up the build process, only include the files you need in order to resolve symbols. In a decent build process, the compiler only compiles files whose source or include file has changed; the others are only linked, which speeds up the process.Thomas Matthews
Your example is possible, but i don´t get what´s the problem.deviantfan

2 Answers

2
votes

It's very useful and avoid to circular include :

Soppose you have x.h : in head of x.hYou should define :

#ifndef X_H
#def X_H

///CODE of x.h

#endif X_H

Then you should create a includes.h and according to dependencies , include your header files in includes.h

Finally: Every where you want to include each files you only do :

#include "includes.h"
0
votes

I have found where the problwm was. If you're using global include file it can't contain includes for sub-includes which defines class and vars. Like if you want in main use someting from test you can't put test.h include to includes.h ...