-1

I am reading Accelerated C++ and there are lines written there about standard header

It is worth noting that although we refer to our own headers as header files, we refer to the implementation-supplied headers as standard headers rather than standard header files. The reason is that header files are genuine files in every C++ implementation, but system headers need not be implemented as files.

My first question is that if we are running windows OS and in one hand we have codeblocks (GNU compiler) and in second we have turbo c++. So do we consider them as separate implementation?

My second question is that how actually these standard headers are implemented?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
OldSchool
  • 2,123
  • 4
  • 23
  • 45

2 Answers2

3

The point the author is making is that the compiler, should it wish to do so, could implement #include <string> internally in the compiler, without there ever being any file called string in the system that compiles your code. In reality, I'm not aware of any compiler that DOES implement this, but it's certainly viable from what the C++ standards perspective.

Each compiler vendor, such as GNU and Free Software Foundation for gcc, the people at Illinois University behind clang, the people at Microsoft, Borland, IBM, Intel, etc that produce a compiler will produce "an implementation" of a compiler. If I write my own C++ compiler that will be an implementation. I happen to have my own compiler for the language Pascal (written in C++ and using LLVM as the backend) - which is an implementation of the language Pascal - and like all implementations, it follows the standard, but has some "implementation defined" features. All implementations will have some things that are "based on what the implementor choose to do", for several possible reasons:

  1. The standard is not specific: size of int or Pascal's integer is not specified beyond "it must be at least this big ...", so as long as the minimum criteria is fulfilled, the implementor can do what he/she/they chooses.
  2. Extensions - something that goes beyond the standard. Often the standard has restrictions or missing functionality that the implementor may decide to "improve" (this does make the implementation "non-standard", but if the extension doesn't alter the behaviour of standard compliant code, it's "safe" to add) [for example, Pascal doesn't have "names on files", so a Pascal program can't create a file by a particular name - most implementations do have SOME way to create a file by a particular name as an extension]
  3. Standard specifies "implementation defined behaviour" - similar to non-specific, the standard can say that "this is up to the implementor to do as she/he/they wish".
Mats Petersson
  • 126,704
  • 14
  • 140
  • 227
2

tl;dr an "implementation" here is an implementation of the theoretical abstract machine called "C++"

You are confusing IDEs/editors and compilers.

GCC 5.1 is a compiler/linker/toolchain/standard library implementation ("implementation" overall).

As is Visual C++ 2015 (though this nomenclature also extends to the IDE itself; thanks, Microsoft!).

As is your Turbo C++ product that is older than C++ and older than you are.

CodeBlocks is an IDE that invokes a toolchain. It may or may not be the same one as you're using with your ancient Turbo C++ installation, though I very much doubt it since your Turbo C++ requires a DOS emulator to run (ROFL).

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • Inb4 he's older than Turbo. – Hatted Rooster Jul 19 '15 at 17:06
  • Isn't Visual C++ the "compiler/linker/toolchain/standard library implementation", whereas Visual Studio is an IDE (for multiple programming languages)? – Christian Hackl Jul 19 '15 at 17:17
  • @ChristianHackl: Yeah, I suppose that's closer, though Visual C++ itself is still billed as an IDE. Unfortunately it's hard to be exact because MS literally don't distinguish between IDE and compiler. You're right in that Visual Studio is a suite (of IDEs and implementations), though. – Lightness Races in Orbit Jul 19 '15 at 17:19
  • TBH the whole point of an IDE is that it's Integrated. A compiler which merely ships with an editor tailored to editing code isn't really an IDE. That said, it's embarrassing how poor the VC++ integration with the Windows SDK is. (Yes, I know, different groups at Microsoft - OS and tools) – MSalters Jul 20 '15 at 06:44
  • @MSalters: Integration doesn't require tight coupling, though. That is, integration in usage and integration in implementation are two different things. Look at Eclipse, CodeBlocks, all of that: you can use whatever compiler you want. Sure, to a degree you can hack it about in VS, too, but the fact that the VC++ compiler is literally in the same package as the GUI tells you everything. – Lightness Races in Orbit Jul 20 '15 at 09:35
  • I know what a hack it becomes, non-standard compilers in Visual Studio. Just look at Qt. Visual Studio knows almost all compiler and linker options, and can even relate them. (E.g. LTCG works quite well, demand-loaded libraries too). But where it really shines is in the debugger. – MSalters Jul 20 '15 at 12:01