"configure" 脚本如何检测我的系统是否支持某些头文件或 cpp 功能?

How does "configure" script detect if my system support some header files or cpp feature?

我正在尝试在我的 RHEL 5 机器上编译 google rpc(grpc),配置脚本检查并抛出此错误:

configure: error: sched_yield was not found on your system

我检查了 config.log 文件并发现了这样的东西:

| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| char sched_yield ();
| int
| main ()
| {
| return sched_yield ();
|   ;
|   return 0;
| }
configure:19729: result: no
configure:19736: error: in `/downloads/grpc/third_party/protobuf':
configure:19738: error: sched_yield was not found on your system

嗯,没错,我手动测试了一下,没有找到。没问题。

But, I just wish to know the principle behind "configure"!

"configure" 是否尝试生成一些 c/c++ 源代码并编译它,以查看是否支持某些功能?如您所知,"configure" 脚本通常 运行 非常快,比调用大量 gcc/g++ 进程尝试 headers/features.

快得多

那么 "configure" 是如何做到这一点的 header/feature "check"?

Does "configure" try to generate some c/c++ source code and compile it, in order to see if some features are supported?

是的。

As you know the "configure" script usually run very fast [...]

根据我的经验,这不是。 configure 很慢wwwwww...

So how does "configure" achieve this header/feature "check"?

参见问题 #1。