深入到predefined功能 [英] Deep into the predefined functions

查看:161
本文介绍了深入到predefined功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,究竟是如何Çpredefined库函数像Prinf(),scanf()的,罪(X),ABS()等作品。他们是如何定义的,哪里是这些功能的身体所在。

I want to know , exactly how C predefined library functions like Prinf() ,scanf(),sin(x),abs() etc works . How they are defined and where is these functions body resides.

如果我对这些功能点击右键,在Visual Studio中选择视图定义,它显示像这样(像printf)INT __cdecl的printf(_In_z_ _Printf_format_string_为const char * _format,...);

If I right click on these functions and select view definition in visual studio, it shows like this (for printf) int __cdecl printf(_In_z_ _Printf_format_string_ const char * _Format, ...);

我怎么能看到这些功能的内部?

How can I see the inner part of these functions ?

推荐答案

如果您实现船舶与(或以其他方式提供)来源$ C ​​$ C为它的运行时库,这就是你会发现它。

If your implementation ships with (or otherwise makes available) the source code for its runtime library, that's where you would find it.

您应该先问问自己这是否是的必要的。的ISO标准的整点是要确保每一个实现的相同的抽象机,不管底层code的。

You should first ask yourself whether that's necessary. The whole point of the ISO standard is to ensure every implementation is the same abstract machine, regardless of the underlying code.

这意味着你通常应该只是code为标准,而无需担心是否例如,的qsort 被实现为一个快速排序,归并排序,甚至,应该它会不会太关心性能,冒泡排序或BOGO排序。

That means you should generally just code to the standard without worrying whether, for example, qsort is implemented as a quick sort, merge sort or even, should it be not too concerned with performance, a bubble sort or bogosort.

要知道,它会遵循标准中规定的规则。

Just be aware that it will follow the rules as laid out in the standard.

如果您的还是的希望检查库的来源,像 GCC 将使用的glibc (可这里)和Visual C ++源$ C ​​$ C船舶与产品为好。在我的版本(VS 2013年),它在 C:\\ Program Files文件(x86)的\\微软的Visual Studio 12.0 \\ VC \\ CRT \\ SRC

If you still want to examine the source for the library, something like gcc will use glibc (available here) and Visual C++ source code ships with the product as well. On my version (VS 2013), it's in C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\crt\src.

例如,因为你前pressed在你对 ABS意见有权益()功能,这里是从VC ++变种 abs.c 上面列出该目录:

For example, since you expressed an interest in one of your comments about the abs() function, here's the VC++ variant from abs.c in that directory listed above:

int __cdecl abs (int number) {
    return (number >= 0 ? number : -number);
}

有没有多少有这令人惊讶,但像 output.c ,它提供了常见的code所有的printf 式的功能,在约两个半千行时钟。

There's not much there that's surprising but something like output.c, which provides the common code for all the printf-style functions, clocks in at about two and a half thousand lines.

这篇关于深入到predefined功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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