sabottenda/libclang-sample — pull request #1 by nglevin (2014-01-11 04:46:10+00:00)
Title: Mac OS X 10.9 fixes

These changes allow all of the examples to build and run in Mac OS X 10.9 with Clang 3.4.

There were two issues with the code as it was. One was that the regular expression used for the CodeComplete sample used the GNU sed extension `\+`, which is not found in sed on Mac OS X.

The other issue, and the most troublesome one, is that Mac OS X 10.9 comes with two C++ standard libraries; the GNU project's [libstdc++](http://gcc.gnu.org/libstdc++/) 6.0.9, and the LLVM project's [libc++](http://libcxx.llvm.org/). Previous versions of OS X only came with libstdc++.

On 10.9, these libraries are both located in /usr/lib. However, libstdc++ has its header files located in /usr/include/c++/4.2.1. libc++, on the other hand, has its header files located in /Library/Developer/CommandLineTools/usr/lib/c++/v1, which is not a standard system path on OS X at all.

Mac OS X 10.9 defaults to using libc++. I chose to override that default to use libstdc++ instead.

If we wanted to use libc++ in 10.9, I have confirmed that adding -I/Library/Developer/CommandLineTools/usr/lib/c++/v1 to the `CFLAGS` works fine. However, this only works in OS X 10.9 with Xcode's Command Line Tools package installed. Without that package, the headers for libc++ aren't even installed in 10.9. Prior versions of OS X don't even have libc++ to begin with.

For backward compatibility and to avoid any dependencies on Xcode's Command Line Tools, changing the default C++ standard library to libstdc++ on OS X made the most sense to me.

Please let me know if there are any issues with this pull request.

Thank you for your time. Do take care.