What is -ffreestanding option in gcc?

CGccCompilationFreestanding

C Problem Overview


What is ffreestanding in gcc ? What is it used for ? I came across the following :

gcc -ffreestanding -m32 -c kernel.c -o kernel.o

and do not understand, what does it mean exactly.

C Solutions


Solution 1 - C

A freestanding environment is one in which the standard library may not exist, and program startup may not necessarily be at "main". The option -ffreestanding directs the compiler to not assume that standard functions have their usual definition.

By default, GCC will act as the compiler for a hosted implementation, defining __STDC_HOSTED__ as 1 and presuming that when the names of ISO C functions are used, they have the semantics defined in the standard. To make it act as a conforming freestanding implementation for a freestanding environment, use the option -ffreestanding. It will then define __STDC_HOSTED__ to 0, and not make assumptions about the meanings of function names from the standard library.

For more Info, This link may help.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionsaplingProView Question on Stackoverflow
Solution 1 - CDayal raiView Answer on Stackoverflow