我编译的标准库中的 std::endl 在哪里?

Where is std::endl in my compiled standard library?

我正在尝试通过错位名称从我的 C++ 标准库中查找函数。我在 macOS 上,所以使用 nm 命令我可以检查 dylib:

nm -g /usr/local/lib/libc++.dylib
nm -g /usr/local/lib/libc++abi.dylib

在输出中,我可以找到 std::cout 的损坏名称:

0000000000079ec0 S __ZNSt3__14coutE
0000000000079f60 S __ZNSt3__15wcoutE
etc... 

但是,我没有找到 std::endl 的任何条目。

有趣的是,我的 LLVM IR 解释器也找不到 std::endl,尽管 std::cout 工作正常:

LLVM ERROR: Program used external function     
'__ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_' which could not be resolved!

我应该在系统的什么地方找到 std::endl

正如 YSC 提到的,std::endl 是一个函数(可能是内联的),它所做的只是输出结束行 \n 字符然后调用 flush.

http://en.cppreference.com/w/cpp/io/manip/endl

看起来 libcxx 隐藏 endl: https://github.com/llvm-mirror/libcxx/blob/master/include/ostream#L999

虽然 flush 没有这样的属性:https://github.com/llvm-mirror/libcxx/blob/master/include/ostream#L938