0

For every Header File , I was taught something like a full form denoting a purpose of its call

For Example:

1.

  #include<cstdio>

meant include C standard input output files

  #include<iostream>

meant include input output streams

  1. #include

meant include C math files for mathematical operations


In the same manner for

#include<bits/stdc++.h>

what is the full form or basically how its name tells us about the files being included ?

it like

include bits/ standard library of c++

what's meaning of bits and also what's the significance of / in header file name


and one more thing to be clarified is

in modern C++ compilers, addition of .h for any other header file is not allowed but how its allowed here ?


  • 4
    Related (am not sure if duplicate): [Why should I not #include ?](https://stackoverflow.com/questions/31816095/why-should-i-not-include-bits-stdc-h) – Algirdas Preidžius Jun 14 '21 at 08:55
  • your examples are C headers, but `bits/stdc++.h` is a C++ header – 463035818_is_not_an_ai Jun 14 '21 at 08:55
  • 2
    One day... I'm going to create one of those programming competition sites which _deliberatly_ chokes when any of those horrendous "recommended shortcuts" are used. Maybe that'll help produce better programmers. – Mike Vine Jun 14 '21 at 08:56
  • @463035818_is_not_a_number yeah.. even in c++ too `#include` means include input and output streams and so on ...... i have taken only C examples as`.h` is present in C header files –  Jun 14 '21 at 08:58
  • *in modern C++ compilers, addition of .h for any other header file is not allowed but how its allowed here ?* There's nothing "not allowed". The text in `<>` or `""` is a filename. C++ standard library headers have no extenstion. C standard library header files have `.h` extension, user defined headers may have any extension, although you should probably stick to `.h`/`.hpp`. – Yksisarvinen Jun 14 '21 at 08:58
  • @MikeVine best of luck!!!! –  Jun 14 '21 at 08:59
  • the reason I left the comment was that you tagged the question as C, but this question is not about C. – 463035818_is_not_an_ai Jun 14 '21 at 08:59
  • `conio.h` no longer exist on most systems. it's not part of C (and clearly, not C++ as it got .h extension). In C++ you have to include `cstdio` and `cmath`. `#include` includes a file from folder `bits`. `sys` and `bits` folders in GNU-compatible environment are platform and compiler dependant respectively. `bits` are files used internally and not meant for user consumption – Swift - Friday Pie Jun 14 '21 at 08:59
  • @Yksisarvinen cool .....you cleared my 2nd question doubt !!!!! Thanks –  Jun 14 '21 at 09:00
  • @463035818_is_not_a_number okay ... –  Jun 14 '21 at 09:01
  • @AlgirdasPreidžius NO definitely not the question you tagged tells us what all header files are a part of `#include` but nothing about its name !!! –  Jun 14 '21 at 09:03
  • @MaheshKumar what's in the name? You can literally include any file if it would compile as code. It tells nothing but that you had included a file with that name. There are documents which regulate standardized names, then you would have own files, you would have libraries and etc. – Swift - Friday Pie Jun 14 '21 at 09:07
  • @Swift-FridayPie but why `bits` and ` \ ` are present their should be significance of the name too!!!!......................all header file names in c/c++ have been named denoting its purpose .....and iam sure their is some significance for the name of header file too!!!! –  Jun 14 '21 at 09:11
  • 2
    @MaheshKumar "_NO definitely not_" In that case, you are free to look for the person who implemented that file, in your compiler, and ask them for the meaning of the name. Since, as the question I linked, explains - it is **not** a standard header. It is a compiler-specific header. – Algirdas Preidžius Jun 14 '21 at 09:21
  • @Swift-FridayPie ohh i dint know abt this history of `#include` –  Jun 14 '21 at 09:22
  • bit/stdc++.h is custom header for GCC. MSVC, Clang or any other C++ compiler don't support it, should avoid it when compile on other compiler. bit/stdc++.h is include some common header for almost developer, but it will make more large binary and compile more time if developer doesn't use it, but still compile it. bit/stdc++ is suitable for student competitive programming for fast typing, but bad pattern for professional career. – Khoi V Jun 14 '21 at 09:23
  • @KhoiV....yeah !! thanks!! –  Jun 14 '21 at 09:26
  • @AlgirdasPreidžius –  Jun 14 '21 at 09:26
  • .h extension is compatible with plain C header, for mix plain C code in C++ code. Before C++ 98 standard, C++ still use .h extension for header. After namespace is introduced, C++ doesn't need .h extension anymore but still keep it as compatible with old header – Khoi V Jun 14 '21 at 09:28
  • ohh............. –  Jun 14 '21 at 09:30
  • In the intro comment in the file, it has "This is an implementation file for a precompiled header." To me this means: don't include this file directly, because it is an implementation file. – Eljay Jun 14 '21 at 11:24

1 Answers1

1

It's not a predefined file actually and name doesn't have meaning except it was made intentionally distinctive. It could be decoded as "standard C++" which is as misguided as it may get. Name itself appearance is contemporary to appearance of Morozov's STL library, so it may related to namespace std. I can call a file <Those_Are_Very_Imprtant_Declarations.h> or <a123126>, that's just the same.

Historically that file was included into examples of some C++ guides , essentially replacing all required includes and declarations with one-liner. Usually there was description of that file somewhere or how to replace that line, some books included floppy or CD. The content of file is not agreed upon, but usually it included all headers used in examples. Sometimes it contains using namespace std; line. In some cases there are some type definitions, that was typical for versions that predate C++98\03, e.g. before stdint.h \ cstdint was present.

The thing is, the C++ language appeared in 1987 with first implementations available as early as 1988, but standard appeared only in 1998. Before that every compiler had some quirks, implemented one or or another feature differently, had alternative names for headers. STL appeared in 90s and was an "external" library. C++primers usually were mentioning which proprietary compiler they are compatible with or offered list of compatible versions. The header would make it easier by creating "standard" environment for every implementation in which all book's examples and exercises will work.

That's history of the name.

Afaik GNU environment may include that because it was used in tests and for creation of precompiled headers. E.g., this is content of file for libstdc++ run-time included with GCC 4.8. You can see #ifdef that separates C++11 headers from C++98. Leter there appears more.

But not every platform with C++ compiler, not every GCC flavor may have access to this file as a part of libstdc++ run-time library, to which this name is linked today. Presence of using namespace std; in some non-GNU versions makes them dangerous and content of file changes from version to version.

Greatest disadvantage of using that file is portability. There is also concern of using it without precompiling headers, because the content of whole standard library is huge (around a million lines and growing) and adds compilation time. In a big projects that may add minutes and hours of time to compile.

Swift - Friday Pie
  • 12,777
  • 2
  • 19
  • 42