C语言 gcc 中的 -ffreestanding 选项是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17692428/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 06:55:21  来源:igfitidea点击:

What is -ffreestanding option in gcc?

cgcccompilationfreestanding

提问by saplingPro

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

什么是ffreestanding在GCC?它是干什么用的 ?我遇到了以下情况:

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

and do not understand, what does it mean exactly.

不明白,这到底是什么意思。

回答by Dayal rai

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

一个freestanding环境是一个标准库可能不存在的环境,程序启动可能不一定在“主”。该选项-ffreestanding指示编译器不要假设标准函数具有其通常的定义。

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.

默认情况下,GCC 将充当托管实现的编译器,定义__STDC_HOSTED__为 1 并假定当使用 ISO C 函数的名称时,它们具有标准中定义的语义。要使其成为独立环境的符合标准的独立实现,请使用选项-ffreestanding。然后它将定义__STDC_HOSTED__为 0,并且不会对标准库中函数名称的含义进行假设。

For more Info, Thislink may help.

有关更多信息,链接可能会有所帮助。