# C++17 on FreeBSD 10?



## HenryHu (Apr 17, 2018)

One port I maintain has upgraded and requires C++17 language & library features, such as std::any. Is it possible to support it on FreeBSD 10?
Using G++ does not work, because the executable produced uses both libstdc++ and libc++ and crashes. 
An ideal solution may be providing libc++ in ports and using llvm50+libc++ from ports to build this port, but this is not the case now.


----------



## tankist02 (Apr 17, 2018)

clang-devel from ports is version 7, should well support C++17


----------



## HenryHu (Apr 18, 2018)

Yes, the language part is ok, the clang50 from llvm50 already supports C++17 language features.
However, I need library features, which are not available from those ports. For example, one of the new header files from C++17 is "any". For FreeBSD 11, you can find it at /usr/include/c++/v1/any. It is not installed by any clang/llvm ports.


----------



## kpedersen (Apr 18, 2018)

It might not be a viable solution but when I was using (pre-clang) OpenBSD it did not have support for C++11 library stuff. I.e std::shared_ptr<T> was still in technical report namespace ::std::tr1.
Since I just needed to do demos to students using it, I found Emscripten to be quite a decent "hack".

It should work for FreeBSD too. Basically compile up Emscripten using the latest "fastcomp" (based on clang) compiler, and it should provide the latest C++17 featurs when compiled with the "-std=c++1z" flag. This should work because it doesn't use system libraries, it provides entirely its own system libraries.


----------

