1

Topic: How correctly to connect h - files?

There is a desire to reduce the code, entering the reduced titles of types. Therefore the mentioned below file, which then "" to ALL remaining files of the project is created:

#include <QString>
#include <string>
#include <vector>
#include <regex>
typedef const QString cQString;
typedef const std:: string cstring;
typedef const std:: vector cvector;
typedef const std:: regex cregex;
typedef const std:: string:: size_type csize_type;

I correctly understand, what thereby at me the code strongly inflates, after all the directive "#include" recursively interposes initial the code string, vector and regex into all files of my project?
What consequences at such approach?

2

Re: How correctly to connect h - files?

AlekseySQL;
Open for itself

using namespace std

include - a text insertion
The compiler/linker duplication remove

3

Re: How correctly to connect h - files?

Siemargl wrote:

AlekseySQL;
Open for itself

using namespace std

include - a text insertion
The compiler/linker duplication remove

Duplication that remove, but not in each file even these data types are once necessary to me. If to develop my approach half of standard library will be connected to each file in process of project growth + half of library Qt...

4

Re: How correctly to connect h - files?

"Is connected" - there is no such term. Speak correctly, differently it is not clear

5

Re: How correctly to connect h - files?

AlekseySQL wrote:

the mentioned below file, which then "" to ALL remaining files of the project is created:

#include <QString>
#include <string>
#include <vector>
#include <regex>

I correctly understand, what thereby at me the code strongly inflates, after all the directive "#include" recursively interposes initial the code string, vector and regex into all files of my project?

Strange went people...
After all it is enough to open one-two normal title and to see something like:

#ifndef __
#define __
...
#endif

But, of course, to spend hour or so at a forum is much easier, than most  for five minutes.
P.S. Compile time - yes, gives.
Therefore, laziness should be justified, instead of simply laziness.

6

Re: How correctly to connect h - files?

Siemargl wrote:

"is connected" - there is no such term. Speak correctly, differently it is not clear

"Include directive adds ("connects") the code which is allocated in the specified file in the initial text. In other words, the total code consists of two pieces of the program:"connected"library and initial. If in initial texts of programs with the help include to register all possible lib files initial texts logically should swell strongly.
Here about it actually and a question: whether correctly I understand all also what else there are consequences at similar practice.

7

Re: How correctly to connect h - files?

AlekseySQL;
It is more compile time, well and all

8

Re: How correctly to connect h - files?

Basil A. Sidorov wrote:

After all it is enough to open one-two normal title and to see something like:

#ifndef __
#define __
...
#endif

It is possible more shortly

#pragma once

9

Re: How correctly to connect h - files?

Dima T wrote:

it is passed...
It is possible more shortly

#pragma once

At similar directives the preprocessor includes files of libraries in EACH compilation unit only one time. Compilation unit in With ++ is the file. In other words, as I also wrote to each file of the project on time will be connected a heap of lib files.

10

Re: How correctly to connect h - files?

AlekseySQL wrote:

There is a desire to reduce the code, entering the reduced titles of types.

Small SSD?

11

Re: How correctly to connect h - files?

alex_k wrote:

Small SSD?

Thanks, smile

12

Re: How correctly to connect h - files?

Dima T wrote:

it is passed...
It is possible more shortly

#pragma once

It is possible, but it is not necessary. This  is not general-purpose for all compilers.

13

Re: How correctly to connect h - files?

AlekseySQL wrote:

it is passed...
At similar directives the preprocessor includes files of libraries in EACH compilation unit only one time. Compilation unit in With ++ is the file. In other words, as I also wrote to each file of the project on time will be connected a heap of lib files.

Also it is a problem? Then you should esteem about pre-compilation of titles.

14

Re: How correctly to connect h - files?

White Owl wrote:

This  is not general-purpose for all compilers.

Name two which do not support it. Ancient versions - it is not counted.

15

Re: How correctly to connect h - files?

Dimitry Sibiryakov wrote:

it is passed...
Name two which do not support it. Ancient versions - it is not counted.

Ancient versions just "in the account". In the big offices it is much more difficult to march in step with progress and to update not that that compilers, but also OS.

16

Re: How correctly to connect h - files?

White Owl wrote:

Ancient versions just "in the account". In the big offices it is much more difficult to march in step with
Progress and to update not that that compilers, but also OS.

, MS VC began to support this  in version 2013, that is five years ago. GCC - still
Earlier. Braked only SUN Studio and BCC before passage on clang.

17

Re: How correctly to connect h - files?

Dimitry Sibiryakov wrote:

, MS VC began to support this  in version 2013

According to  - with VS2003.

18

Re: How correctly to connect h - files?

AlekseySQL;
Yes it is normal,  titles just for that treatment that you are afraid
Good an article

19

Re: How correctly to connect h - files?

Dimitry Sibiryakov wrote:

it is passed...
, MS VC began to support this  in version 2013, that is five years ago. GCC - still
Earlier. Braked only SUN Studio and BCC before passage on clang.

And I here write till now for the compiler:

 $/usr/vac/bin/xlc-qversion
C for AIX version 6.0.0.0$ 

And yes, to be updated in plans is... Here already like even as dared... Like... It seems...

20

Re: How correctly to connect h - files?

kealon (Ruslan) wrote:

AlekseySQL;
Yes it is normal,  titles just for that treatment that you are afraid
Good an article

To tell the truth, an article not on a subject smile
Excites not speed of compilation (with which  precompiled titles), and swelling of the code from - for adding of unnecessary declarations in all files of the project. From - for it sensation that code maintainability is reduced.

21

Re: How correctly to connect h - files?

AlekseySQL;
Rates, we go from determinations
What do you name code size? An output after a preprocessor? Well so it is delirium

wrote:

#include "recursively interposes initial the code string, vector and regex into all files of my project?

macroes if are not used that not interposed. You are afraid that if you in two cpp-files use, for example, std:: vector that its code will be interposed in  to everyone cpp in which it used, and then counterparts will not be cut off ?
code maintainability depends on the programmer

22

Re: How correctly to connect h - files?

kealon (Ruslan) wrote:

you are afraid that if you in two cpp-files use, for example, std:: vector that its code will be interposed in  to everyone cpp in which it used, and then counterparts will not be cut off ?

Yes, I also am afraid of it:)

23

Re: How correctly to connect h - files?

AlekseySQL;
Google extern template

24

Re: How correctly to connect h - files?

AlekseySQL wrote:

it is passed...
Yes, I also am afraid of it:)

It absolutely copecks. It is necessary to pay attention to it only if you program under something much less, than the cheap smart phone.
And if you it is simple  I booze include <> and did not use (not ) their classes and functions their code will not be interposed anywhere and at all does not form.

25

Re: How correctly to connect h - files?

AlekseySQL wrote:

I correctly understand, what thereby at me the code strongly inflates, after all the directive "#include" recursively interposes initial the code string, vector and regex into all files of my project?

No, incorrectly.

AlekseySQL wrote:

What consequences at such approach?

At such approach awful consequences.
At first, not what for to write such foolish , they will confuse only.
using - instructions would suffice above a roof.
Secondly, you have a look that you there , and think, whether really you want it...