[cfe-dev] _LIBCPP_INLINE_VISIBILITY and std::string::length

Alexey Kudinkin alexey.kudinkin at gmail.com
Fri Mar 8 11:09:43 PST 2013


Hello!

I'm just curious about what are the reasons to forcing inlining of that sort of functions like std::string::length? Precluding them to be included into libc++ binary breaks linkage of the following snippet of code 

> int main(int ARGC, char *ARGV[])() {
> 
>   std::vector<std::string>  pray = { "I", "will", "not", "aim", "for", "the", "head" };
>   std::vector<size_t>       lengths;
> 
>   std::transform(pray.begin(), pray.end(), std::back_inserter(lengths), std::mem_fn(&std::string::size));
> 
>   return 0;
> 
> }

with the error:

> Undefined symbols for architecture x86_64:
>   "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::length() const", referenced from:
>       _main in assignment-F0ysIg.o
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see invocation)

Best regards,
Alexey Kudinkin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130308/fa967a71/attachment.html>


More information about the cfe-dev mailing list