如何在不使用标准C库的情况下使用编译器内置函数 [英] How to use compiler builtin functions without Standard C library

查看:166
本文介绍了如何在不使用标准C库的情况下使用编译器内置函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道某些函数,例如 sin cos min max memcpy 可能不会被视为普通函数,但可能会被内置函数(可能比仅内联更为优化)函数调用,当替换是实际的处理器指令时,例如直接为标准 sin FSIN 指令为带有浮点单元的x86编译时,$ c>函数。)

I know that some functions like sin cos min max memcpy may be treated not as normal functions but may be replaced by built-in functions (which may be more optimal than merely inline function calls, when the replacement is (an) actual processor instruction(s), such as directly calling the FSIN instruction for standard sin function when compiled for an x86 with a floating point unit).

我想使用内置函数的功能(在C / C ++中,大多数是在mingw / gcc中使用)也许是其他编译器),但我不想链接到标准C库libc。)

The question I would like to use power of built-in functions (in C/C++ mostly in mingw/gcc maybe other compiler) but I do not want to link to libc, the Standard C Library).


  • 是否可以使用不链接的内置函数到libc?

  • Is it possible to use builtins with not linking to libc?

它们是否有任何命令行标记需要优化这些符号作为内置符号?

Are they any command line flags needed to optimize those symbols as a built-ins?

(相关

它们将被名称自动识别,还是启用该功能所必需的编译器标志

Will they be automatically recognized by name, or are compiler flag(s) necessary to enable usage of built-ins?

推荐答案

让我们说你想要替换功能 cos ,您要做的就是用<$替换代码中每次出现的 cos 。 c $ c> __ builtin_cos 。您可以用编译器版本替换的任何其他功能也是如此。只需在名称前加上 __ builtin _

Lets say you wanted to replace the function cos, all you have to do is replace every occurance of cos in your code with __builtin_cos. The same goes for any other function that you can replace with the compiler's version. Just prepend __builtin_ to the name.

有关更多信息,请参见 gcc手册

For more information consult the gcc manual.

这篇关于如何在不使用标准C库的情况下使用编译器内置函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆