What kind of software is part of an "Implementation" exactly when stating "Implementation-defined"? What is an "Implementation" exactly?

I often see the statement "implementation-defined" in the C Standard documentations, as well as getting it as answer very much.

I have then searched in the C99 Standard for it, and:

In ISO/IEC 9899/1999 (C99) is stated under §3.12:

3.12

Implementation

particular set of software, running in a particular translation environment under particular control options, that performs translation of programs for, and supports execution of functions in, a particular execution environment

As well under §5:

  1. Environment

An implementation translates C source files and executes C programs in two dataprocessing-system environments, which will be called the translation environment and the execution environment in this International Standard. Their characteristics define and constrain the results of executing conforming C programs constructed according to the syntactic and semantic rules for conforming implementations.

But to which software applications exactly it refers to?

Which set of software in particular?

It is stated as providing a translation AND an execution environment. So it couldn´t be the compiler alone, or am i wrong about this assumption?

About which parts of my system i can think of as part of "the implementation"?

Is it the Composing of the used Compiler with its relying C standard, the operation system, the C standard used itself or a mix between those all?

Does it despite the previous statement also include a piece of hardware (used processor, mainboard, etc)?

I quite do not understand, what an implementation exaclty is.

I feel like i have to be a 100-year experienced cyborg to know what it all includes entirely and exactly.

Upvotes: 3

Views: 136

Answers (3)

R.. GitHub STOP HELPING ICE
R.. GitHub STOP HELPING ICE

Reputation: 215287

I think you have a good formal sense of what it is, and are focusing your question on specifics of real-world implementations, so that's what I'll address. "The implementation" actually tends to encompass a number of components which act and depend upon one another via a number of interface contracts, all of which need to be honored in order to have any hope of the implementation as a whole being conforming.

These include possibly:

  • the compiler
  • possibly an assembler, if the compiler produces asm as an intermediate form
  • the linker
  • library code that's part of the standard library (which is part of the language, as the language is specified, not a separate component, but only for hosted implementations not freestanding ones)
  • library code that's "compiler glue" for implementing language constructs for which the compiler doesn't directly emit code (on GCC, this is libgcc), often used for floating point on machines that lack hardware fpu, division on machines that lack hardware divider, etc.
  • the dynamic linker, if the implementation uses dynamic-linked programs
  • the operating system kernel, if the implementation's library functions don't directly drive the hardware, but depend on syscalls or "software interrupts" or similar defined by the operating system having their specified behavior in order to implement part of the standard library or other (e.g. startup or glue) library code
  • etc.

Arguably you could also say the hardware itself is part of the implementation.

Upvotes: 3

lucidbrot
lucidbrot

Reputation: 6156

The C99 Standard defines many things, but some are just not that relevant so they did not care to define them in the Standard in detail. Instead, they write "implementation defined" which means that whoever actually programs a compiler according to their standard can choose how exactly they do that.

For example, gcc is an implementation of that standard (Actually, gcc implements various different Standards, as pmg points out in his comment. But that's not too important right now). If you were to write your own compiler, you can only call it a "C99 Compiler" if it adheres to the standard. But where the standard states that something is implementation dependent, you are free to choose what your compiler should do.

Upvotes: -1

dbush
dbush

Reputation: 224127

Generally speaking, an "implementation" refers to a given compiler and the machine it runs on. The latter is important due to things such an endianness, which dictates the byte ordering of integer and floating point types, among other considerations.

An implementation is required to document its implementation defined behavior. For example you can find GCC's implementation defined behavior here.

Compilers often support multiple versions of the C standard, so each operating mode can also be considered an implementation. For example, you can pass the -std option to GCC to specify c89, c99. or c11 modes.

Upvotes: 4

Related Questions