There are two forms of corresponding implementations defined by the c standard:
- Hosting and
- Freelance implementation
They are based on two types of envrionments, which the c standard defines as:
- Hosting Environment &
- Freelance environment, respectively.
What is a freestanding Environment and what is a freestanding Environment ?
A freelance implementation is a program designed for programs that run without using the operating system. For Ex: The OS kernel or embedded environment will be a standalone environment.
A program that uses the operating system is usually located in a hosted version.
How is a c program executed in these two environments? What is the difference?
How C runs in both of these environments. For a Freestanding environment, a program can start using any function defined by a definition. It is not required that even << 22> exist .
Thus, any of the function definitions mentioned in the question may be valid depending on the implementation for this autonomous environment. Both their function parameters and return values will have a specific implementation value, so you will need to check their documentation to find out their exact values.
Link:
5.1.2.1 Freelance
In a stand-alone environment (in which C program execution can be performed without any advantage of the operating system), the name and type of function called in the startup program are implementation specific . Any libraries available for a stand-alone program other than the minimum set required in accordance with clause 4 are determined by the implementation.
For a hosted environment, the standard indicates that program execution begins with the main() function, and also determines how this function will be defined.
Specifications for them are given in:
C99 Standard: 5.1.2.2 Hosting Environment
5.1.2.2.1 Starting the program
1 The function called when the program starts is called main. The implementation does not declare a prototype for this function. It is defined with an int return type and without Parameters:
int main(void) { }
or with two parameters (called argc and argv here, although any names can be used since they are local to the function in which they are declared):
int main(int argc, char *argv[]) { }
or equivalent; or some other way of implementation.